Abort sms broadcast and/or delete received sms from inbox

半世苍凉 提交于 2019-12-07 17:53:52

问题


I am trying to write sms encryption tool. People using this tool will be able to chat without internet via sms and stay encrypted. The only thing I need is how to stop sms from particular number from getting into inbox folder, or delete sms notification and then delete sms from inbox.

I googled a lot, but https://stackoverflow.com/a/3875736/705297 this is not working. Broadcast is working, I see the log message that broadcastreceiver is launched, but it doesn't abort broadcast.

Also I found lots of messages that it is impossible. So is it possible and how I can do that? I am using android 2.1 and higher. Thanks

Code (just tries to cancel all sms for testing purposes): Broadcast receiver:

  @Override
  public void onReceive(Context context, Intent intent)
  {
      abortBroadcast(); }

Part of manifest:

<uses-permission android:name="android.permission.RECEIVE_SMS" />

 <receiver android:name=".SMSReceiver">
    <intent-filter android:priority="1000">
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>

回答1:


I also need to have BROADCAST_SMS permission. That was my problem. Here is the working part of manifest.

<uses-permission android:name="android.permission.BROADCAST_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
....
 <receiver android:name=".SMSReceiver" android:permission="android.permission.BROADCAST_SMS">
          <intent-filter android:priority="1000">
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>


来源:https://stackoverflow.com/questions/9699774/abort-sms-broadcast-and-or-delete-received-sms-from-inbox

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