Sms Receive With No Notification
Solution 1:
set priority in your intent-filter // in manifest
<intent-filter android:priority="100"> /*your receiver get high priority*/
// in broadcast receiver
if (keyword_match)
{
// Stop it being passed to the main Messaging inboxabortBroadcast();
}
Solution 2:
This should be possible by registering your app to receive SMS messages and then using abortBroadcast() when you detect your message has arrived. You say abortBroadcast() doesn't work - is the SMS definitely getting handled by your SMS receiver?
For anybody else wanting to do this, read on...
First, declare the SMS receiver in your AndroidManifest.xml and make sure the app has permission to receive SMS messages.
<receiverandroid:name="mypackage.SMSReceiver"><intent-filter><actionandroid:name="android.provider.Telephony.SMS_RECEIVED"/></intent-filter></receiver><uses-permissionandroid:name="android.permission.RECEIVE_SMS" />
Here's some example code to handle the SMS messages:
publicclassSMSReceiverextendsBroadcastReceiver
{
@OverridepublicvoidonReceive(Context context, Intent intent)
{
Bundleextras= intent.getExtras();
Object[] pdus = (Object[])extras.get("pdus");
for (Object pdu: pdus)
{
SmsMessagemsg= SmsMessage.createFromPdu((byte[])pdu);
Stringorigin= msg.getOriginatingAddress();
Stringbody= msg.getMessageBody();
// Parse the SMS bodyif (isMySpecialSMS)
{
// Stop it being passed to the main Messaging inbox
abortBroadcast();
}
}
}
}
Solution 3:
You should not do this. Other apps might want or need to receive the SMS_RECEIVED broadcast. Aborting it will disrupt 3rd party apps from running properly. This is a bad way to program. you should only abort broadcasts that you create, not system broadcasts. I don't know why the Android OS lets you do this.
Solution 4:
not sure if i know exactly what you are trying to do but from what i understand you just want to know how to not send a notification?
why cant you just do:
If(instance 2){
//do your processing
}else{
//send notification
}
if you mean you want to block the OS from broadcasting it then you might be out of luck because i dont believe you can do that
Solution 5:
yo need android:priority attribute for that to work
<intent-filterandroid:priority="1"><actionandroid:name="android.provider.Telephony.SMS_RECEIVED" /></intent-filter>
Post a Comment for "Sms Receive With No Notification"