实际上,我希望构建一个 Intent 服务来接收 SMS,如您所知,我们使用 Intent 服务来执行异步任务。现在在我的应用程序服务中监听传入的 SMS,然后将其存储在 dbase 中并关闭,当收到短信时再次监听,然后它监听短信并存储它并关闭我该怎么做。请在这方面帮助我。提前致谢,如果我不明白,请原谅我的发音不好..
谢谢你的问候
Om Prakash Kaushik..
最佳答案
你需要一个广播接收器。
在您的 list 中您需要声明权限;
<uses-permission android:name="android.permission.RECEIVE_SMS">
然后声明接收短信的类
<receiver android:name=".SMSBroadcastReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
然后声明你的类
public class SMSBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//intent contains SMS data
}
}
关于android - Intent 服务接收短信并关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11840899/