Java – Android opens a specific SMS-Thread through its Thread-ID

Android opens a specific SMS-Thread through its Thread-ID… here is a solution to the problem.

Android opens a specific SMS-Thread through its Thread-ID

My plan is to open an SMS session thread by thread ID. My code is:

    long threadId = Long.parseLong(THREAD_ID);

Intent defineIntent = new Intent(Intent.ACTION_VIEW);
    defineIntent.setData(Uri.parse("content://mms-sms/conversations/"+threadId));
    context.startActivity(defineIntent);

But I get the following error:

09-27 16:01:07.696: ActivityNotFoundException: No Activity found to
handle Intent { act=android.intent.action.VIEW
dat=content://mms-sms/conversations/3 }

Can anyone help me with this? Thanks in advance.

J Doe 😉

Solution

I found the solution myself. It works because every message from a particular number goes into a thread. If you use “new-sms-intent” with the number you received the text message at instead of the contact name, it will open the entire conversation.

Only one line:

context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", "SMS_NUMBER_AS_STRING_HERE", null)));

Related Problems and Solutions