I set the alarmMgr like this:
alarmMgr.setRepeating(AlarmManager.RTC, calendar.getTimeInMillis(),
1000 * 60 * 5L, alarmIntent)
and BroadcastReceiver output
public class BroadcastReciever extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
System.out.println("Execute time:" + Calendar.getInstance().getTime());
}...}
I got the correct log yesterday, then It's go wrong. It looked like trigger the alarm many times in the same time and I dont know why.I guess may be the android studio logcatch has some unknown mechanism.
2022-04-14 10:44:40.447 8663-8663/com.example.ss I/System.out: ...
2022-04-14 10:46:40.441 8663-8663/com.example.ss I/System.out: ...
2022-04-14 10:48:40.440 8663-8663/com.example.ss I/System.out: ...
2022-04-14 10:50:40.444 8663-8663/com.example.ss I/System.out: ...
2022-04-14 10:52:40.446 8663-8663/com.example.ss I/System.out: ...
I catch the log whole night, a part of the Log shows below. the system log shows here ,
2022-04-15 07:33:39.945 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 07:33:39 GMT+09:00 2022
2022-04-15 07:33:39.951 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 07:33:39 GMT+09:00 2022
2022-04-15 07:33:39.954 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 07:33:39 GMT+09:00 2022
2022-04-15 07:33:39.960 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 07:33:39 GMT+09:00 2022
2022-04-15 07:33:39.963 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 07:33:39 GMT+09:00 2022
2022-04-15 07:33:39.966 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 07:33:39 GMT+09:00 2022
2022-04-15 07:33:39.969 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 07:33:39 GMT+09:00 2022
2022-04-15 07:35:40.066 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 07:35:40 GMT+09:00 2022
2022-04-15 08:40:40.096 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 08:40:40 GMT+09:00 2022
2022-04-15 08:40:40.103 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 08:40:40 GMT+09:00 2022
2022-04-15 08:40:40.106 13580-13580/com.example.ss I/System.out: Execute time:Fri Apr 15 08:40:40 GMT+09:00 2022
About the methods(inexact/actual time),official page said system would trigger together of some alarm in order to save battery, Alarm stats shows that, there is no so cloesd Alarm at all.I have got the correct output sometimes. I also tested method at interval 15mins, the output still went wrong.I don't think the reason is inexact methods.
Alarm Stats:
1000:android +6s300ms running, 353 wakeups:
+3s273ms 0 wakes 40 alarms, last -4m9s148ms:
alarm:com.android.server.action.NETWORK_STATS_POLL
+2s837ms 0 wakes 226 alarms, last -4m9s148ms:
alarm:TIME_TICK
+699ms 347 wakes 347 alarms, last -1h41m9s348ms:
walarm:job.delay
+102ms 0 wakes 1 alarms, last -4m9s148ms:
alarm:GraphicsStatsService
+60ms 2 wakes 2 alarms, last -2h14m49s133ms:
walarm:ScheduleConditionProvider.EVALUATE
+31ms 0 wakes 1 alarms, last -8h39m9s148ms:
alarm:android.intent.action.DATE_CHANGED
+9ms 1 wakes 1 alarms, last -13h27m11s167ms:
walarm:JS idleness
+8ms 1 wakes 1 alarms, last -19h41m4s292ms:
walarm:RETRY
+6ms 2 wakes 2 alarms, last -17h41m9s348ms:
walarm:job.deadline
u0a40:com.android.providers.calendar +364ms running, 4 wakeups:
+364ms 4 wakes 4 alarms, last -1h39m9s148ms:
walarm:com.android.providers.calendar.intent.CalendarProvider2
u0a89:com.android.systemui +470ms running, 27 wakeups:
+470ms 27 wakes 27 alarms, last -14h38m7s109ms:
walarm:com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD
u0a113:com.example.ss +4s532ms running, 0 wakeups:
+4s532ms 0 wakes 185 alarms, last -4m9s148ms:
alarm:com.example.ss/.BroadcastReciever`