如何打开短信意图阅读(不发送)消息? [英] How to open SMS intent to read (not send) message?

查看:117
本文介绍了如何打开短信意图阅读(不发送)消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用android.provider.Telephony.SMS_RECEIVED收听传入的SMS.我成功地从发件人处捕获了SMS正文和SMS编号.我想使用Android Intent打开带有正文和数字的SMS应用程序(当您收到SMS并打开SMS应用程序以查看详细信息时类似).我该如何在Android 5.0中做到这一点?我正在使用以下代码,但这是用于发送消息.这意味着它打开了具有数字和正文+发送按钮的窗口.我不要那个窗户我只想阅读GUI

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

推荐答案

如何在Android 5.0中做到这一点?

How can I do it in Android 5.0?

ACTION_VIEW不收取额外费用.确实需要Uri.如果您具有对Sms提供程序的读取访问权限,欢迎尝试在收件箱中查找消息,然后尝试对该消息使用ACTION_VIEWUri.但是,不要求任何Android设备上的应用程序都具有支持此功能的活动.

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.

这篇关于如何打开短信意图阅读(不发送)消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆