Android 检测短信传入和传出

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2735571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:09:29  来源:igfitidea点击:

Detecting SMS incoming and outgoing

androidsms

提问by soclose

I'd like to detect sms incoming and outgoing automatically from my application at background whenever this app is opening or not. how to code?

无论何时打开此应用程序,我都想在后台自动检测从我的应用程序传入和传出的短信。如何编码?

回答by hcpl

This is a good tutorial on both sending and receiving sms messages: http://mobiforge.com/developing/story/sms-messaging-android.

这是一个关于发送和接收短信的好教程:http: //mobiforge.com/developing/story/sms-messaging-android

For the incoming messages you can indeed configure a broadcastlistener for detection. *

对于传入的消息,您确实可以配置广播侦听器进行检测。*

Detecting outgoing messages is also possible (just altered this post since I dind't know this). from: http://www.mail-archive.com/[email protected]/msg26420.html

检测传出消息也是可能的(只是更改了这篇文章,因为我不知道这一点)。来自:http: //www.mail-archive.com/[email protected]/msg26420.html

ContentResolver contentResolver = context.getContentResolver();
  contentResolver.registerContentObserver(Uri.parse("content://
sms"),true, myObserver);

回答by Samuh

System broadcasts appropriate messages when messages are sent and received. You will have to create BroadCastReceiver for appropriate Intents(see documentation for details ... I think it is android.provider.Telephony.SMS_RECEIVEDfor interception not sure of sending though)

系统在发送和接收消息时广播适当的消息。您必须为适当的 Intent 创建 BroadCastReceiver(有关详细信息,请参阅文档...我认为这是android.provider.Telephony.SMS_RECEIVED为了拦截,但不确定发送)