mercredi 25 février 2015

Messages not being blocked on Android 4.4 and higher despite priority set to highest. Is there a workaround?



Blocking SMS but it doesn't seem to work on Android version 4.4 and higher. This has been discussed elsewhere on Stackoverflow, but no known workaround so far. Is there anything that can be done to have a priority greater than the default SMS app? Here the code I use :



if (MSG_TYPE.equals("android.provider.Telephony.SMS_RECEIVED")) {
// Toast toast = Toast.makeText(context,"SMS Received: "+MSG_TYPE , Toast.LENGTH_LONG);
// toast.show();

Bundle bundle = intent.getExtras();
Object messages[] = (Object[]) bundle.get("pdus");
SmsMessage smsMessage[] = new SmsMessage[messages.length];
for (int n = 0; n < messages.length; n++) {
smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
String body = smsMessage[0].getMessageBody().toString();
String num = smsMessage[0].getOriginatingAddress().toString();
try {
for (String a : mBlackList) {
if (PhoneNumberUtils.compare(a, num)) {
abortBroadcast();
if (preferences.getBoolean("show_notif", true)) {
showNotification(num, body);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}



Aucun commentaire:

Enregistrer un commentaire