如何执行的Android在接收时的动作和短信? [英] 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.
推荐答案
您将需要使用广播接收器
和的IntentFilter
。检查出来,在SDK参考。
You will need to use a BroadcastReceiver
and an IntentFilter
. Check them out in the SDK reference.
如果您注册一个的IntentFilter
在的AndroidManifest.xml
您注册的广播接收器
那么它会被你的广播接收器
在后台采摘。看看意图
并提供了行动。
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. Look at Intent
and the actions provided.
这篇关于如何执行的Android在接收时的动作和短信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!