I have two Broadcast Receivers :
Sending SMS.
Manage notification.
I have to call both receivers at a specified time.
How can i do that?? is it possible?
The code for calling notification alarm is given below:
AlarmManager alarmManager=(AlarmManager) context.getSystemService(context.ALARM_SERVICE);
Intent intent=new Intent(context,specialNotification.class);
Bundle bu=new Bundle();
bu.putString("TITLE", title);
bu.putString("BODY", body);
bu.putInt("ICON", icon);
bu.putLong("TIME", t);
intent.putExtras(bu);
//Toast.makeText(context, ""+_id, 3000).show();
//Toast.makeText(context, "REpeat Alarm", 3000).show();
PendingIntent pi=PendingIntent.getBroadcast(context, _id, intent, 0);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, t, MILLISECONDS_IN_YEAR, pi);
Please help me to call SMS receiver
Thanks in advance..
I believe you can create a new Intent
for your SMS broadcast receiver, and PendingIntent
, passing it a different id value than the one you passed to the PendingIntent
of your notification.
AlarmManager alarmManager=(AlarmManager) context.getSystemService(context.ALARM_SERVICE);
Intent notifIntent = new Intent(context,specialNotification.class);
Intent smsIntent = new Intent(context,Your_SMS_Receiver.class);
Bundle bu=new Bundle();
bu.putString("TITLE", title);
bu.putString("BODY", body);
bu.putInt("ICON", icon);
bu.putLong("TIME", t);
intent.putExtras(bu);
PendingIntent notifPI = PendingIntent.getBroadcast(context, NOTIFICATION_ID, notifIntent, 0);
PendingIntent smsPI = PendingIntent.getBroadcast(context, SMS_ID, smsIntent, 0);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, t, MILLISECONDS_IN_YEAR, notifPI);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, t, MILLISECONDS_IN_YEAR, smsPI);