Set alarm for 1 min but it called after 5 minutes

I have set alarm for 1 minutes but it called after every 5 minutes.

AlarmManager alarmManager = (AlarmManager)getActivity().getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(getActivity(), MyBroadcastReceiver.class);
intent.setAction("com.example");
PendingIntent pendingIntent = PendingIntent.getBroadcast(getActivity(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); //pending intent
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, new Date().getTime(), 60000, pendingIntent); //time duration is 60 seconds

1 Answer

USE alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, new Date().getTime(), 60000, pendingIntent); //time duration is 60 seconds Instead of alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, new Date().getTime(), 60000, pendingIntent); //time duration is 60 seconds

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like