Hi everyone,

 

I have a "calendar" feature in my app that the user will be able to select a
day and time and set an event. My problem is if the date is the current date
the alarmIntent fires off immediately, not waiting for the proper time. I
have been running tests with it and I set the time for the current day and a
few minutes in the future via a datePicker and a TimePicker. Below is my
code.

 

//Set Alarm

                     alarmEvent =
(AlarmManager)getSystemService(Context.ALARM_SERVICE);

                     String ALARM_ACTION;

                     ALARM_ACTION = EventAlarmReceiver.ACTION_EVENT_ALARM;

                     Intent intentToFire = new Intent(ALARM_ACTION);

                     

                     Calendar cal = Calendar.getInstance();

                     cal.set(Calendar.DAY_OF_MONTH,
dpEvent.getDayOfMonth()-1);

                     cal.set(Calendar.MONTH, dpEvent.getMonth());

                     cal.set(Calendar.YEAR, dpEvent.getYear());

                     cal.set(Calendar.HOUR, tpAddEvent.getCurrentHour());

                     cal.set(Calendar.MINUTE,
tpAddEvent.getCurrentMinute());

                     

                     

                     alarmEventIntent = PendingIntent.getBroadcast(this, 0,
intentToFire, 0);

                     

                     int alarmType = AlarmManager.RTC_WAKEUP;

                     long timeToNotify = cal.getTimeInMillis();

                     alarmEvent.set(alarmType, timeToNotify,
alarmEventIntent);

 

 

Now when I check the timeToNotify variable and use a website to convert the
Millisecond time to regular time, it shows me the correct time that I set on
the phone. I am confused as to why it fires off immediately.

 

If I set the event for a day in the future it does not go off immediately. I
will have to wait until tomorrow to verify that it does go off.

 

Any help or input is greatly appreciated!

 

Tommy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to