Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I setup multiple alarms in Android?
    text
    copied!<p>So far and thanks to this website, I've been able to set up an alarm that will be set up and active, even if I turn of my phone.</p> <p>Now, I set up a alarm to show a reminder for event A and I need the application to setup another alarm to show <strong>another</strong> reminder for event B.</p> <p>I must be doing something wrong, because it only fires the reminder for event A. It seems that once set up, any other alarm is understood as the same one. :-(</p> <p>Here is the detail of what I am doing in two steps:</p> <p>1) From an activity I set an alarm that at certain time and date will call a receiver</p> <pre><code> Intent intent = new Intent(Activity_Reminder.this, AlarmReceiver_SetOnService.class); intent.putExtra("item_name", prescription .getItemName()); intent .putExtra( "message", Activity_Reminder.this .getString(R.string.notif_text)); intent.putExtra("item_id", itemId); intent.putExtra("activityToTrigg", "com.companyName.appName.main.Activity_Reminder"); PendingIntent mAlarmSender; mAlarmSender = PendingIntent.getBroadcast( Activity_Reminder.this, 0, intent, 0); long alarmTime = dateMgmt.getTimeForAlarm(pickedDate); Calendar c = Calendar.getInstance(); c.setTimeInMillis(alarmTime); // Schedule the alarm! AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, alarmTime + 15000, mAlarmSender); </code></pre> <p>2) From the receiver I call a service</p> <pre><code> Bundle bundle = intent.getExtras(); String itemName = bundle.getString("item_name"); String reminderOrAlarmMessage = bundle.getString("message"); String activityToTrigg = bundle.getString("activityToTrigg"); int itemId = Integer.parseInt(bundle.getString("item_id")); NotificationManager nm = (NotificationManager) context.getSystemService("notification"); CharSequence text = itemName + " "+reminderOrAlarmMessage; Notification notification = new Notification(R.drawable.icon, text, System.currentTimeMillis()); Intent newIntent = new Intent(); newIntent.setAction(activityToTrigg); newIntent.putExtra("item_id", itemId); CharSequence text1= itemName + " "+reminderOrAlarmMessage; CharSequence text2= context.getString(R.string.notif_Go_To_Details); PendingIntent pIntent = PendingIntent.getActivity(context,0, newIntent, 0); notification.setLatestEventInfo(context, text1, text2, pIntent); notification.flags = Notification.FLAG_AUTO_CANCEL; notification.defaults = Notification.DEFAULT_ALL; nm.notify(itemId, notification); </code></pre> <p>Thanks in Advance,</p> <p>monn3t</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload