Android4.4 can not handle sms intent with “vnd.android-dir/mms-sms”

╄→гoц情女王★ 提交于 2019-11-28 07:38:24

To start the SMS app with number populated use action ACTION_SENDTO:

Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("smsto:" + Uri.encode(phoneNumber)));
startActivity(intent);

This will work on Android 4.4. It should also work on earlier versions of Android however as the APIs were never public the behavior might vary. If you didn't have issues with your prior method I would probably just stick to that pre-4.4 and use ACTION_SENDTO for 4.4+.

to start the sms app without insert the number, you should delete setType

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
intent.putExtra("sms_body", "smsMsgVar");
startActivity(intent);

The issue happened when you are testing with Emulator,

Please test with the actual device.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!