2016-07-27 57 views
1

默认短信应用打开特定对话我使用的代码从这样的回答:How to open specific sms in Android和它完美的作品。如何在Android中6(API 23)

但在设备上Android 6.0apiVerion >= 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版本的工作?

+0

我想是因为权限。您应该在Android 6.0以上的版本中处理SMS权限。 :)请检查[this](https://developer.android.com/training/permissions/requesting.html) – SripadRaj

+0

@SripadRaj谢谢,这是个好主意,但这不是问题。我确信我已经授予READ_SMS许可。 要找出会话** threadId **我搜索收到的短信中的特定文本,找到后我会在默认应用中打开它。如果我有权限问题,我无法找到** threadId **。还有整个短信相关的代码是在这种情况下: 'if(ActivityCompat.checkSelfPermission(App.context,android.Manifest.permission.READ_SMS)== PackageManager.PERMISSION_GRANTED){' 您还有其他猜测吗? –

+0

我想这是无法正确解决意图。也许尝试设置类型意图是这样的? 'intent.setType(“vnd.android-dir/mms-sms”);' – SripadRaj

回答

0

我找到了一个解决方法:我没有在默认应用程序中通过SMS线程的ID打开SMS对话,但是通过电话号码打开。它在Android 6中以这种方式工作。

Intent androidSix = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", "phone_number_in_string", null)); 
startActivity(androidSix); 
相关问题