问题
My job is to create SMS APP to hide selected numbers so that from falling further into default SMS app, this task is simple API for AND <19 using this code.
public class SMSReceiver extends BroadcastReceiver {
public static String TAG = "SMSReceiver";
ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
public SMSReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
SMS_Throttle.VytvorDatabazi(context);
String act = intent.getAction();
Log.d(TAG, act);
if (Dtb.HodnotaZNastaveniINT(ENastaveni.START_SKRYTE_SLUZBY, 1) == 1) {
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
boolean isAbort = false;
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
String lst[][] = SMS_Throttle.getTlfCisla(context);
String[] l = new String[lst.length];
for (int j = 0; j < lst.length; j++)
l[j] = lst[j][0];
for (int i = 0; i < msgs.length; i++) {
msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
for (int j = 0; j < l.length; j++) {
if (msgs[i].getOriginatingAddress().endsWith(l[j])) {
if (Dtb.HodnotaZNastaveniINT(ENastaveni.PRISLA_AKTIVITA, 0) == 1) {
tg.startTone(ToneGenerator.TONE_DTMF_5, 30);
Toast.makeText(context, msgs[i].getMessageBody(), Toast.LENGTH_LONG).show();
}
isAbort = true;
Dtb.UlozActivitu(l[j], msgs[i].getMessageBody(), EKomunType.RECEIVE_SMS);
}
}
}
}
if (isAbort) {
abortBroadcast();
}
}
}
}
Important:
Earlier versions of the API perfect shot abortBroadcast (). Thus, if the sender's number is listed in my list see the condition if (msg [i] .getOriginatingAddress (). EndsWith (l [i])) {then the SMS will be saved in my database and do not fall into default app for text messaging.
If the number is not listed in my list, then into my database to store MUST but you must fall into default messaging app.
Problem arose in API> = 19 where the abortbroadcast not work at all and moreover were removed right at the possibility of deletion of selected SMS from default SMS app.
Advise someone how to solve the problem when you need to use my SMS receiver while the default? I've already read through almost everything http://android-developers.blogspot.cz/2013/10/getting-your-sms-apps-ready-for-kitkat.html but also many posts on stackoverflow but I never thought to address this encountered.
Thanks for every idea