How to open SMS intent to read (not send) message?

2020-04-30 16:11发布

I am using android.provider.Telephony.SMS_RECEIVED to listen to incoming SMS. I was successful catch SMS body and SMS number from the sender. I want to open the SMS application with the body and the number using Android Intent(similar when you receive an SMS and open SMS app to see detail). How can I do it in Android 5.0? I am using the bellow code, but it is for sending a message. It means it opened the window that has number and body +send button. I don't want that window. I just want reading GUI

        Intent smsIntent = new Intent(Intent.ACTION_VIEW);
        smsIntent.setType("vnd.android-dir/mms-sms");
        smsIntent.putExtra("address", SMSNumber);
        smsIntent.putExtra("sms_body",SMSBody);
        smsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(smsIntent);

1条回答
啃猪蹄的小仙女
2楼-- · 2020-04-30 17:06

How can I do it in Android 5.0?

ACTION_VIEW does not take extras. It does take a Uri. If you have read access to the Sms provider, you are welcome to try to find the message in the inbox, then try ACTION_VIEW with the Uri to that message. However, there is no requirement that any Android device have an app with an activity that supports this.

查看更多
登录 后发表回答