1

Explanation: I have calendar in which i set the events on the particular day of the given month.The event is stored into the database. on the event day is occurs it is trigger an alarm to notice the user.

suppose, my event is save on the 29/05/2016 then my alarm is triggered on the particular date.

Notice:i have multiple event created on the particular month.e.g. on the 29th may or 30th may also.

MyQuestion is how can i fire the multiple alarm on the particular multiple days.

Please, understand the flow what i exactly want?

Milan Gajera
  • 962
  • 2
  • 14
  • 41

2 Answers2

-1

If you want to play alarm for particular date and time , following code may help you

Calendar cal=Calendar.getInstance();
cal.set(Calendar.MONTH,5);
cal.set(Calendar.YEAR,2012);
cal.set(Calendar.DAY_OF_MONTH,11);

cal.set(Calendar.HOUR_OF_DAY,16);
cal.set(Calendar.MINUTE,10);
cal.set(Calendar.SECOND,0);

Intent _myIntent = new Intent(getApplicationContext(), ReceiverClass.class);
PendingIntent _myPendingIntent =      
PendingIntent.getBroadcast(getApplicationContext(), 123, _myIntent,   
PendingIntent.FLAG_UPDATE_CURRENT|  Intent.FILL_IN_DATA);
AlarmManager myAlarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
//myAlarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() +   (10 * 1000), _myPendingIntent);
myAlarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),  _myPendingIntent); 
mdDroid
  • 3,135
  • 2
  • 22
  • 34
  • Are you refer my post on stackoverflow if not please refer http://stackoverflow.com/questions/37475398/how-can-i-call-my-alarm-at-the-time-of-event-occurs-in-android/37475561#37475561 – Milan Gajera May 27 '16 at 09:55
-1
 calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR,date.getYear());
        calendar.set(Calendar.MONTH,date.getMonth()+1);
        calendar.set(Calendar.DAY_OF_MONTH,date.getDate());
        calendar.set(Calendar.HOUR_OF_DAY,time.getHours());
        calendar.set(Calendar.MINUTE,time.getMinutes());
        calendar.set(Calendar.SECOND,time.getSeconds());
        Intent myIntent = new Intent(context, AlarmReciever.class);
        myIntent.putExtra("ReminderDetails",reminderDetails);

        myIntent.putExtra("requestCode", requestCode);
        pendingIntent = PendingIntent.getBroadcast(context, (int) (requestCode), myIntent,0);
            alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, date.getTime(),
                    interval, pendingIntent);

The following code here is good live for setting a calender time at the specified time and date. And the most important thing here stands is that what do you pass in 2nd argument in alarmManager.setInexactRepeating(_) method,which is date.getTime(), which is the only thing will work instead of using calendar.getTimeinMillis() method, because that will return some unexpected time to be launched for intents.

Siddharth Choudhary
  • 1,069
  • 1
  • 15
  • 20