This is how I am setting the priority of my application intent filter highest.After receiving the intent Extras I abort the broadcast, but the native app is still receiving the sms and notification bar is still showing the message content which is most annoying as I dont want it to show message body. Is there something I am missing??
<receiver android:name=".MySmsReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"
android:priority="999"
/>
</intent-filter>
</receiver>
this is my receiver's onReceive()
method
public void onReceive(final Context context, Intent intent) {
Bundle extras = intent.getExtras();
abortBroadcast();
....
}
Try to declare your receiver in this way :
<receiver android:name=".MySmsReceiver">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
Instead of :
<receiver android:name=".MySmsReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"
android:priority="999"
/>
</intent-filter>
</receiver>
Also try to check the following condition before aborting your broadcast :
EDITED :
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(SMS_RECEIVED)) {
Bundle extras = intent.getExtras();
if(extras != null)
// doBroadcast();
else
abortBroadcast();
}
}
Hope it helps you.
Thanks.