Before Android 4.0, Alarmmanager was fine. Later, in order to optimize the power consumption of the system, Android introduced the doze mode, see this page
Https://developer.android.com/training/monitoring-device-state/doze-standby
Simply put, the system will automatically enter the Doze mode after the standby time, this mode, Alarmmanager what is not good use, the system will automatically from Doze mode for a short period of time, the just in Doze ignored events (such as Alarmmanager) execution. In this way, Alarmmanager cannot be called at all.
In fact, for each application, this mode is configurable, generally in Settings > Battery > Battery optimization, you can also use code to open the Settings page, let the user set, the following is a code written by others:
New Intent (settings.action_request_ignore_battery_optimizations); Intent.setdata (Uri.parse ("package:user.zhuku.com")); StartActivity (intent);
Huawei watches, there are similar options on Wear OS 2.0.
Android 8.0 Alarmmanager Background Timer task