Android English document translation series (1) -- AlarmManager, alarmmanager

Source: Internet
Author: User

Android English document translation series (1) -- AlarmManager, alarmmanager

Original article: Personal translation, limited level. Please refer to the official correction. Public classAlarmManagerextends Object
Java. lang. Object
Bytes Android. app. AlarmManager
Class Overview

This class provides access to the system alarm services.

This class can provide access to the system alarm service,

These allow you to schedule your application to be run at some point in the future.

He allows you to schedule your applications to run at a certain time point in the future.

When an alarm goes off,IntentThat had been registered for it is broadcast by the system,

When the alarm time is reached, register the Intent for system broadcast,

Automatically starting the target application if it is not already running.

The target program will be automatically run if the program is not started.

Registered alarms are retained while the device is asleep (and can optionally wake the device up if they go off during that time), but will be cleared if it is turned off and rebooted.

 

 

The Alarm Manager holds a CPU wake lock as long as the alarm receiver's onReceive () method is executing.

 

 

This guarantees that the phone will not sleep until you have finished handling the broadcast.

 

Once onReceive () returns, the Alarm Manager releases this wake lock.

 

This means that the phone will in some cases sleep as soon as your onReceive () method completes.

 

If your alarm extends Er calledContext.startService(), It is possible that the phone will sleep before the requested service is launched.

 

To prevent this, your BroadcastReceiver and Service will need to implement a separate wake lock policy to ensure that the phone continues running until the service becomes available.

 

 

Note: The Alarm Manager is intended for cases where you want to have your application code run at a specific time,Even if your application is not currently running. 

Note:

 

 

For normal timing operations (ticks, timeouts, etc) it is easier and much more efficient to useHandler.

Handler is simpler and more efficient for most scheduled operations (reminders, timeouts, etc.

You do not instantiate this class directly; instead, retrieve it throughContext.getSystemService(Context.ALARM_SERVICE).

You do not need to instantiate its object. You only need to get it through Context. getSystemService (Context. ALARM_SERVICE.

 

 

 

English is too good, and my consciousness is still vague. I need to strengthen my English and read more English documents.

 

When the device is sleeping, the registered alarm will be retained (if the time is reached, it will wake up the device), but if the alarm is turned off or the alarm is restarted, the previous settings will be cleared. Alarm Manager runs the onReceive () method of the receiver that maintains the CPU activation status to the Alarm clock broadcast. This will ensure that the phone will not sleep unless you end the broadcast event processing. If onReceive () is returned once, Alarm Manager releases the wake-up lock. This means that your phone is sleeping in a certain situation, and your onReceive () method will end. If the receiver of the alarm notification is calledContext.startService()Your mobile phone may sleep before the requested service is running. To prevent the above situation, your broadcast receiver and service must implement an independent device wake-up mechanism to ensure that your mobile phone can continue to run unless the service has taken effect.Alarm ManagerIt is for the application in this case, when you need to let your program run at a specific time, even if your program is not running.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.