Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open up a specific SMS in android

Is there a way to open up the Messaging Activity on android with a specific SMS?

like image 623
n179911 Avatar asked Sep 11 '09 17:09

n179911


2 Answers

threadId should be the id of the SMS/MMS thread you want to view

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

This is the simplest way I found

like image 76
Valay Avatar answered Oct 27 '22 06:10

Valay


Try this

int req_thread_id;

Uri mSmsinboxQueryUri = Uri.parse("content://sms"));
Cursor cursor1 = getContentResolver().query(
                        mSmsinboxQueryUri,
                        new String[] { "_id", "thread_id", "address", "person", "date",
                                "body", "type" }, null, null, null);

startManagingCursor(cursor1);
if (cursor1.getCount() > 0)
{
while (cursor1.moveToNext())
{

int thread_id = cursor1.getInt(1);
String address; = cursor1.getString(cursor1
                            .getColumnIndex(columns[0]));
if("your desired no".equals(address)
 req_thread_id = thread_id;
}
}
Intent defineIntent = new Intent(Intent.ACTION_VIEW); 
defineIntent.setData(Uri.parse("content://mms-sms/conversations/"+req_thread_id));  
myActivity.startActivity(defineIntent);
like image 32
Vibhuti Avatar answered Oct 27 '22 07:10

Vibhuti