2

I am using the code from this answer:How to open specific sms in Android and it works perfectly.

But on Devices with Android 6.0 (apiVerion >= Build.VERSION_CODES.M) my App crashes.

CrashLog:

 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 }

How can I make it work for this Android version?

Community
  • 1
  • 1
Matej Scolopax
  • 189
  • 1
  • 8
  • I guess its because of permission. You should handle SMS permission at runtime in android 6.0 onwards. :) Please check [this](https://developer.android.com/training/permissions/requesting.html) – SripadRaj Jul 27 '16 at 12:37
  • @SripadRaj thank you- it's good gues, but it is not the problem. I am sure I have granted permission to READ_SMS. To find out conversation **threadId** I search for specific text in received SMS's and after it was found I am opening it in default app. If I had permission problem, I would not be able find **threadId** in first place. And olso whole SMS related code is inside this condition: `if (ActivityCompat.checkSelfPermission(App.context, android.Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED) {` Do you have any other guesses? – Matej Scolopax Jul 27 '16 at 13:49
  • i guess it is unable to resolve the intent properly. Maybe try setting type to intent like this? `intent.setType("vnd.android-dir/mms-sms");` – SripadRaj Jul 27 '16 at 15:59
  • No luck. It Still does not work. But thank you anyway. – Matej Scolopax Aug 01 '16 at 09:49

1 Answers1

1

I have found a workaround: I do not open SMS Conversation in default app by the id of SMS thread, but by the phone number. And it works this way in Android 6.

Intent androidSix = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", "phone_number_in_string", null));
startActivity(androidSix);
Matej Scolopax
  • 189
  • 1
  • 8