I would like a send an intent to this receiver from another application, which handles SMS. I am quite new to this SMS handling. Can someone kindly guide me on what intent,I mean, how and what and intent should have to execute this piece of receiver code. Thanks.
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;
public class SMSReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
try {
Object[] objArr = (Object[]) extras.get("pdus");
for (Object obj : objArr) {
SmsMessage createFromPdu = SmsMessage.createFromPdu((byte[]) obj);
String displayOriginatingAddress = createFromPdu.getDisplayOriginatingAddress();
String displayMessageBody = createFromPdu.getDisplayMessageBody();
try {
if (displayOriginatingAddress.contains("MADAPP")) {
if (displayMessageBody.contains("The PIN is")) {
Toast.makeText(context, displayMessageBody, 1).show();
}
if (displayMessageBody.contains("successfully validated")) {
displayMessageBody.contains("activating Pockets");
}
}
} catch (Exception e) {
}
}
} catch (Exception e2) {
}
}
}
}