我正在使用此答案中的代码:如何在Android中打开特定的短信,它可以完美运行。
但是在装有Android 6.0(apiVerion >= Build.VERSION_CODES.M
)的设备上,我的应用程序崩溃了。
崩溃日志:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW cat=[android.intent.category.DEFAULT] dat=content://mms-sms/conversations/50 flg=0x10000000 }
如何使它适用于此Android版本?
我找到了一种解决方法:我不是通过SMS线程的ID,而是通过电话号码在默认应用中打开SMS对话。它在Android 6中以这种方式工作。
Intent androidSix = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", "phone_number_in_string", null));
startActivity(androidSix);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句