i set the alarm at specific time but every time i open the application it will turn on this is the code i used :
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,0010000,intent,0);
Calendar time = Calendar.getInstance();
time.set(Calendar.HOUR, 5);
time.set(Calendar.MINUTE, 59);
time.set(Calendar.SECOND, 0);
alarmManager.set(AlarmManager.RTC,time.getTimeInMillis(),pendingIntent);
Instead of placing this code in onCreate function, place it inside any button event or any other event which will be called only on user interaction. I think, that'll do.
add this 'cancel' method to your code. this will cancel the previous alarm before setting the new one.
Alright, you need to set the alarm to ring the next time it is 5:59:00. You do this by getting the current time, if its before 5:59:00, set the alarm, if its after 5:59:00 then add a day and set the alarm. Do it like so:
I wanted to give you a buildable example, but i don't fully understand alarmmanager yet, so this is what you have. Built on eclipse 3.5.2 with ADK 15