android 4.4 设置应用为默认短信的问题

Imp_cyc 2014-11-01 11:50:26
Android4.4以后短信类应用需要设置自己的应用为默认的短信类的应用,但是当我设置button的监听器为:
public void setting(View view) {
//Intent intent = new Intent(MainActivity.this,SendSms.class);
//startActivity(intent);
Log.d("DEFAULT", " The button has responsed!");
Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getPackageName());
startActivity(intent);
Log.d("DEFAULT", "The intent has been responsed!too");
}

的时候,,点击按钮竟然一点反应都没有,,但是两个log都打印了,,这是什么情况??求各位大大帮帮忙
...全文
1898 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_31800771 2016-11-14
  • 打赏
  • 举报
回复
最近我也在短信这块。应用为默认短信应用的的设置,没有做到适配。华为是可以的,酷派却不行。酷派也跳出来选择当前的应用为默认短信应用,但是在系统设置里没有看到,,,是不是因为没有上线的缘故呢?
qq_16125059 2016-03-12
  • 打赏
  • 举报
回复
同问怎么把其他某个应用设置为默认短信应用? 感激不尽~~
我就是爱学习 2016-01-26
  • 打赏
  • 举报
回复
我按照stackoverflow上设置也没用啊,点击button监听器还是没有跳转 有没有大大能贴下相关Manifest的代码,网上找的也基本不能用
暖光 2015-12-14
  • 打赏
  • 举报
回复
问下是如何解决的啊
Imp_cyc 2014-11-02
  • 打赏
  • 举报
回复
谢谢了!问题解决了!
svenwang 2014-11-02
  • 打赏
  • 举报
回复
stackoverflow上有解答,你可以试一下。

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.

So :
1.
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.

2.
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.

3.
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.

4.
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.

80,360

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧