How to perform an action in Android when receiving and SMS?

試著忘記壹切 提交于 2019-12-11 23:42:25

问题


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.


回答1:


You will need to use a BroadcastReceiver and an IntentFilter. Check them out in the SDK reference.

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.



来源:https://stackoverflow.com/questions/4998175/how-to-perform-an-action-in-android-when-receiving-and-sms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!