Android. Error. Pop SMS notification after reboot

白昼怎懂夜的黑 提交于 2019-12-13 02:39:18

问题


I have problem. After my application is installed, SMS broadcast is intercepted successfully . But after reboot, all intercepted SMS broadcast still popup in Notification Bar (from Standard Sms application)

Broadcastreceiver:

public class OwnSmsBroadcastextends BroadcastReceiver{
private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
public void onReceive(Context context, Intent intent) {

        final Bundle bundle = intent.getExtras();
        if (intent.getAction().equals(SMS_RECEIVED)) {
            abortBroadcast();

        try {...

Manifest:

   <receiver android:name=".OwnSmsBroadcast"  android:permission="android.permission.BROADCAST_SMS">
            <intent-filter android:priority="10000">
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
                <action android:name="android.provider.Telephony.SMS_DELIVERED" />
                <action android:name="android.intent.action.BOOT_COMPLETED" /> 
            </intent-filter>
   </receiver>

Why after reboot all intercepted notofications popups?


回答1:


Google Hangouts 2.0 causes problems with SMS_RECEIVED intents. The intent filter is set to the MAX_INTEGER value 2,147,483,647 - which exceeds your value of 10,000. The documentation says that PRIORITY should never exceed 1,000 (the highest value you should set it at is 999) and above that will result in "unpredictable behavior" - although, usually the higher the priority is the order used by Android.

To fix this either disable SMS in Hangouts or uninstall it.

FYI - SMS_DELIVERED is not valid until KitKat (v4.4+) but only the default SMS app will receive it. So it is not necessary unless you also implement several other features in order to be the default SMS app. In KitKat, SMS_RECEIVED is still broadcast so you will be notified, but you cannot abort it.



来源:https://stackoverflow.com/questions/21160559/android-error-pop-sms-notification-after-reboot

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