Alarmmanager contains the main methods:
Cancels a registered timer that matches a parameter
void Cancel (Pendingintent operation)
Register for a new delay timer
void set (int type, long triggerattime, pendingintent operation)
Registering a repeating type of timer
void setrepeating (int type, long triggerattime, long interval, pendingintent operation)
Register a non-precision repeating type timer
void setinexactrepeating (int type, long triggerattime, long interval, pendingintent operation)
Setting the time zone
void Settimezone (String timeZone)
Main types of timers:
public static final int elapsed_realtime
//This type of alarm does not wake the system when the system goes to sleep. Until the next time the system wakes up to pass it, the time spent in the alarm is relative to the time it starts, including the sleep time, which can be obtained by calling Systemclock.elapsedrealtime (). The system value is 3 (0x00000003).
public static final int elapsed_realtime_wakeup
//can wake up the system, using the same elapsed_realtime, the system value is 2 (0x00000002).
public static final int RTC
//This type of alarm does not wake the system when the system goes to sleep. It is not delivered until the next time the system wakes up, the time spent in the alarm is absolute, and the time spent is UTC time, which can be obtained by calling System.currenttimemillis (). The system value is 1 (0x00000001).
public static final int rtc_wakeup
//can wake up the system using the same RTC type with a system value of 0 (0x00000000).
public static final int power_off_wakeup
//can wake up the system, it is a shutdown alarm, that is, the device in the shutdown state can also wake up the system, so we call it shutdown alarm. Using the same method as the RTC type, the system value is 4 (0x00000004).
Alarmmanager Life cycle:
Repeating Alarmmanager Once the boot is running in the background (unless you execute the Cancel method), you can see in app management that the app state is running. "Force stop" can make Alarmmanager stop.
Try several task managers, can only reset the counter (really free memory), but can not turn off the timer, only the system's own "forced stop" worked.
Introduction and use of Android Alarmmanager (timer)