[英]How to perform an action in Android when receiving and SMS?
Can someone please help me figure out how to perform an action when sms is received, is there a special method for it? 有人可以帮我弄清楚收到短信后如何执行操作,是否有特殊的方法? Will it automatically be ran in the background? 会自动在后台运行吗? The only thing I know is that I need to use permission RECEIVE_SMS. 我唯一知道的是我需要使用权限RECEIVE_SMS。
You will need to use a BroadcastReceiver
and an IntentFilter
. 您将需要使用BroadcastReceiver
和IntentFilter
。 Check them out in the SDK reference. 在SDK参考中查看它们。
If you register an IntentFilter
in the AndroidManifest.xml
with your registration of the BroadcastReceiver
then it will be picked by your BroadcastReceiver
in the background. 如果您在注册了BroadcastReceiver
在AndroidManifest.xml
注册了一个IntentFilter
,那么它将由您的BroadcastReceiver
在后台进行选择。 Look at Intent
and the actions provided. 查看Intent
和提供的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.