hey guys i am working on android application , i am trying to creat a notification for a specific time like ( 03 - august -2012 at 5:00 pm ) , so i used the calender to set the time and then using calendar.getTimeInMillis i get the time of the notification , but unfortunatlly when i run my application on the emulator once the application starts the notification appears without caring about the specfic time, i.e its not 4:00 pm the notification appears on the top and time stamped with 5:00pm , heres my notification code :
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.ieee;
CharSequence tickerText = "Hello";
// long when = System.currentTimeMillis();
//setting custom time
Calendar calendar = Calendar.getInstance();
calendar.set(calendar.DAY_OF_MONTH,03);
calendar.set(Calendar.HOUR_OF_DAY,17);
calendar.set(Calendar.MINUTE,26);
calendar.set(Calendar.SECOND, 00);
long when = calendar.getTimeInMillis(); // notification time
Notification notification=new Notification (icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.FLAG_ONLY_ALERT_ONCE;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(1, notification);
now everything is running , but there's a little problem ,,, for example if the date&time now is 9/9/2012 , 9:00 am ,,, and i set the alarm for tomorrow at 10am , okey it will work , but when i open the application the day after tomorrow first thing the app will do is to do notification of the old alarm , i tried this by setting old alarm dates and when i open the app the first thing it does is showing old alarms , so any ideas about solving this ?