How to open up a specific SMS in android

前端 未结 4 585
死守一世寂寞
死守一世寂寞 2021-01-04 09:03

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

4条回答
  •  心在旅途
    2021-01-04 09:56

    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);
    

提交回复
热议问题