using the following code i can abortBroadcast() from my broadcastreciver and bundle the sms and address to my activity, what i am trying to do is abortBroadcast() from my activity, so my activity checks if the address is the same as one of my stored addresses and then abortBroadcast(), but i cant find a way to do this, is it in any way possible to abortBroadcast() from my activity or any way of checking details from an activity then allow the broadcastreciver to abort?
heres my code:
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
// a notification message
String messages = "";
if (extras != null) {
Object[] smsExtra = (Object[]) extras.get("pdus");
for (int i = 0; i < smsExtra.length; ++i) {
SmsMessage sms = SmsMessage.createFromPdu((byte[]) smsExtra[i]);
String body = sms.getMessageBody().toString();// sf
String address = sms.getOriginatingAddress();
messages += "SMS from " + address + " :\n";
messages += body + "\n";
}
Intent data = new Intent(context, Details.class);
data.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
for (int i = 0; i < smsExtra.length; ++i) {
// get sms message
SmsMessage sms = SmsMessage.createFromPdu((byte[]) smsExtra[i]);
String body = sms.getMessageBody().toString();
String address = sms.getOriginatingAddress().toString();
// bundle
Bundle bundle1 = new Bundle();
bundle1.putString("title", body);
bundle1.putString("title2", address);
data.putExtras(bundle1);
context.startActivity(data);
abortBroadcast();
}
}
}
}
in my activity:
Bundle bundle1 = this.getIntent().getExtras();
String title = bundle1.getString("title");
String title2 = bundle1.getString("title2");
((EditText) findViewById(R.id.ettext)).setText(title);
((EditText) findViewById(R.id.etnumber)).setText(title2);
mSms =(TextView)findViewById(R.id.tvsms);
String sms = mSms.getText().toString();
if (sms.equals(title2))
abortBroadcast();????