Set alarm for 1 min but it called after 5 minutes

痞子三分冷 提交于 2019-12-12 03:09:47

问题


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:


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



来源:https://stackoverflow.com/questions/38865893/set-alarm-for-1-min-but-it-called-after-5-minutes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!