FAQS


Message received after auto dailing on message number

Views: 1128  |   Date: 2013-11-20 05:50:22

Our Code

public void onReceive(Context context, Intent intent) {
// Retrieves a map of extended data from the intent.
final Bundle bundle = intent.getExtras();
try {if (bundle != null) {
final Object[] pdusObj = (Object[]) bundle.get("pdus");
for (int i = 0; i < pdusObj.length; i++) {
SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
String phoneNumber = currentMessage.getDisplayOriginatingAddress();
String senderNum = phoneNumber;
String message = currentMessage.getDisplayMessageBody();
Log.i("SmsReceiver", "senderNum: "+ senderNum + "; message: " + message);
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, "senderNum: "+ senderNum + ", message: " + message, duration);
Activity act=new Activity();
String phoneCallUri = "tel:"+senderNum ;
intent= new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(phoneCallUri));
act.startActivity(intent);
toast.show();
}
}

} catch (Exception e) {
Log.e("SmsReceiver", "Exception smsReceiver" +e);

}

 
Submit Your Answer
  |  
 
 
 

Preview :