0

I have 3 different Date objects and I want to pass them to AlarmManager object to alert me when they occur.

May I need to use

 Calendar cal = Calendar.getInstance();
         cal.add(Calendar.MINUTE, 2);

to add 2 minutes to the calender, but how to add a future date object to the calender ?

Do I need A Calender object, or I need a separate Calender object for each Date ? Them for AralamManger do I need one object to 3 ?

frayab
  • 2,512
  • 20
  • 25
Bader
  • 3,656
  • 9
  • 38
  • 55

1 Answers1

0

I will advice you to use three different Calendar objects in which future dates will be set as below:

Calendar calendar1 = Calendar.getInstance();
            Date future_date=new Date();
             future_date.setHours(hour);
                future_date.setMinutes(min);
                future_date.set(year, month, day);
                calendar1.setTime(future_date);

....OR.......
calendar1.set(year, month, day, hourOfDay, minute)
   ----------------

Look like u want to setup multiple alarm...below is link for answer How can I setup multiple alarms in Android?

Community
  • 1
  • 1
Maneesh
  • 6,098
  • 5
  • 36
  • 55
  • and using one AlarmManager object ? – Bader Oct 22 '11 at 08:01
  • am.set(AlarmManager.RTC_WAKEUP, calendar1.getTimeInMillis(), pendingIntent); -----OR -----am.set(AlarmManager.RTC_WAKEUP, future_date.getTime(), pendingIntent); Please set it as Answer if it is useful to you – Maneesh Oct 22 '11 at 08:12
  • ok I will accept the answer , but I can set more than one calnder for the same AlarmManager , right ? – Bader Oct 22 '11 at 08:57
  • U can set multiple alarm with same AlarmManager instance by passing different requestcode....http://stackoverflow.com/questions/3273342/how-can-i-setup-multiple-alarms-in-android – Maneesh Oct 22 '11 at 09:19
  • by setting up pending intent...PendingIntent.getBroadcast(Context context, int requestCode, Intent intent, int flags) – Maneesh Oct 22 '11 at 09:21