Timer (Alarmmanger) has problems with 12AM (00:00 - 00:59)
my application is designed to start a service at a specific time.

I use a **timePicker** to receive the time

     time.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
			
			public void onTimeChanged(TimePicker view, int hourOfDay, int min) {
				hour = hourOfDay;
				minute = min;
			}
		});

You can press a button to activate the **alarmmanager**. The Intent should then start at this time.


    public void onClick(View v) {
				cal = Calendar.getInstance();
				int _hour = hour;
				int tmpHour = cal.get(Calendar.HOUR_OF_DAY);
				int tmpMinute = cal.get(Calendar.MINUTE);
				// Alarm is today?
				if (hour > tmpHour || (tmpHour == hour && tmpMinute < minute)){
					
					tmpHour *= 60;
					_hour *= 60;
				}
				**// Add 24Hours to get difference.
				else {
					 
					tmpHour *= 60;
					_hour *= (_hour + 24) * 60;
				}**
				int minutesToAdd = (_hour + minute) - (tmpHour + tmpMinute);
				Log.d("AlarmExample", "Need to add " + minutesToAdd + " minutes");
				cal.add(Calendar.MINUTE, minutesToAdd);
				

				cal.set(Calendar.SECOND, 0);
				cal.set(Calendar.MILLISECOND, 0);

...


    //alarmmanager

				AlarmManager amanag = (AlarmManager) getSystemService(ALARM_SERVICE);
				amanag .set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);





I have a problem here :
When you pick a time between 12:00 AM and 12:59 AM,  **_hour *= (_hour + 24) * 60;** makes the alarm start immediately when you touch the button.

I tried to change it to  _hour = (_hour + 24) * 60;* but it didn't work.

Do you have any idea how to make this reliable?

Sincerly,
Wolfen


Timer (Alarmmanger) has problems with 12AM (00:00 - 00:59)
===

my application is designed to start a service at a specific time.

I use a **timePicker** to receive the time

     time.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
			
			public void onTimeChanged(TimePicker view, int hourOfDay, int min) {
				hour = hourOfDay;
				minute = min;
			}
		});

You can press a button to activate the **alarmmanager**. The Intent should then start at this time.


    public void onClick(View v) {
				cal = Calendar.getInstance();
				int _hour = hour;
				int tmpHour = cal.get(Calendar.HOUR_OF_DAY);
				int tmpMinute = cal.get(Calendar.MINUTE);
				// Alarm is today?
				if (hour > tmpHour || (tmpHour == hour && tmpMinute < minute)){
					
					tmpHour *= 60;
					_hour *= 60;
				}
				**// Add 24Hours to get difference.
				else {
					 
					tmpHour *= 60;
					_hour *= (_hour + 24) * 60;
				}**
				int minutesToAdd = (_hour + minute) - (tmpHour + tmpMinute);
				Log.d("AlarmExample", "Need to add " + minutesToAdd + " minutes");
				cal.add(Calendar.MINUTE, minutesToAdd);
				

				cal.set(Calendar.SECOND, 0);
				cal.set(Calendar.MILLISECOND, 0);

...


    //alarmmanager

				AlarmManager amanag = (AlarmManager) getSystemService(ALARM_SERVICE);
				amanag .set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);





I have a problem here :
When you pick a time between 12:00 AM and 12:59 AM,  **_hour *= (_hour + 24) * 60;** makes the alarm start immediately when you touch the button.

I tried to change it to  _hour = (_hour + 24) * 60;* but it didn't work.

Do you have any idea how to make this reliable?

Sincerly,
Wolfen

