How to set up a repeating alarm to fire immediately when a Button is pressed and repeat itself in every 4 hrs.?
alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(),
4*60*60*1000, alarmIntent);
Repeats itself but doesnt start immediately when a Button is pressed. it takes 5 mins to fire.
What am I doing wrong here?
I changed the code as below and the alarm is fired immediately
alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, AlarmManager.INTERVAL_FIFTEEN_MINUTES, 4*60*60*1000, alarmIntent);
but it doesn't repeat every 4 hrs. How can I make the alarm repeat every 4 hrs?