问题描述
我将更改Android 4.4.2上的默认短信应用
I would change default sms app on Android 4.4.2
我使用以下代码:
Intent sendIntent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
sendIntent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, context.getPackageName());
startActivity(sendIntent);
我该如何解决?以及如何要求使用我的应用程序更改默认的短信应用程序?
How can i solve this? And how can i ask to change default sms app with my app?
我的接收器:
<receiver android:name="receiver.SMSHandlerReceiver"
android:permission="android.permission.BROADCAST_SMS" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_DELIVER" />
</intent-filter>
</receiver>
谢谢.
推荐答案
似乎,如果您希望您的应用程序出现在默认的短信应用程序设置中,则必须首先使其具备资格,否则您将无法将其设置为默认应用程序短信应用.我遇到了同样的问题,所以我做了这些简单的步骤,然后就可以在设置和代码中选择我的应用程序作为默认应用程序了,这是我以前无法做到的.
It seems that if you want your app to appear in default sms app settings, you must first make it eligible, or else you can not set your app as default sms app. I had the same problem so I did those simple steps and then I could chose my app as default, in settings and in my code, which I could not before.
所以:
-
您必须具有一个活动,该活动包括带有ACTION_SENDTO("android.intent.action.SENDTO")的意图过滤器以及模式sms,smsto,mms和mmsto.在清单文件中执行此操作.我所做的是使用这些参数创建了一个我将不使用的空活动.
You must Have an Activity including an intent filter with an ACTION_SENDTO ("android.intent.action.SENDTO" ) and with schemas sms, smsto, mms, and mmsto. Do it in your manifest file. What I did was creating an empty activity that I will not use, with those parameters.
执行相同的操作,方法是创建一个空服务,该服务包括带有ACTION_RESPOND_VIA_MESSAGE("android.intent.action.RESPOND_VIA_MESSAGE")和模式,sms,smsto,mms和mmsto的意图过滤器.此服务还必须需要SEND_RESPOND_VIA_MESSAGE权限.您必须在清单中添加所有必需的权限.
Do the same, by creating an empty Service including an intent filter with ACTION_RESPOND_VIA_MESSAGE ("android.intent.action.RESPOND_VIA_MESSAGE") and with schemas, sms, smsto, mms, and mmsto. This service must also require the SEND_RESPOND_VIA_MESSAGE permission. You must add all required permissions in your manifest.
使用MIME类型application/vnd.wap.mms-message创建带有WAP_PUSH_DELIVER_ACTION("android.provider.Telephony.WAP_PUSH_DELIVER")的意图过滤器的空BroadcastReceiver.广播接收器还必须要求BROADCAST_WAP_PUSH权限.您必须在清单中添加所有必需的权限.
Create an empty BroadcastReceiver including an intent filter with WAP_PUSH_DELIVER_ACTION ("android.provider.Telephony.WAP_PUSH_DELIVER") with the MIME type application/vnd.wap.mms-message. The broadcast receiver must also require the BROADCAST_WAP_PUSH permission. You must add all required permissions in your manifest.
使用SMS_DELIVER_ACTION("android.provider.Telephony.SMS_DELIVER")创建一个包含意图过滤器的空BroadcastReceiver.广播接收器还必须要求BROADCAST_SMS权限.您必须在清单中添加所有必需的权限.
Create an empty BroadcastReceiver including an intent filter with SMS_DELIVER_ACTION ("android.provider.Telephony.SMS_DELIVER"). The broadcast receiver must also require the BROADCAST_SMS permission. You must add all required permissions in your manifest.
设置所有这些参数而不丢失一个参数很重要.完成所有这些步骤后,您的应用程序将可以使用,然后可以将其设置为默认的短信应用程序,将那些创建的类留空,并坚持使用旧的方法.我们的目标只是将您的应用程序设置为默认应用程序,因此它将像以前一样完全功能化,而无需修改代码.
It important to set all these parameters without missing one. Once you made all these steps, your app will be eligible and you can then set it as default sms app, leaving those created classes empty, and sticking with you old way of doing things. The goal is simply set your app as default, so it will be fully fonctionnal like it was before, without code modification.
这篇关于在Android 4.4.2上更改SMS App默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!