Android英文文档翻译系列(1)——AlarmManager
|
原文:个人翻译,水平有限,欢迎看官指正。
public class
AlarmManagerextends Object
Class OverviewThis class provides access to the system alarm services. 这个类可以提供访问系统闹钟服务, These allow you to schedule your application to be run at some point in the future. 他允许你安排你的的应用在未来某个时间点运行。 When an alarm goes off, the 当闹钟时间到了,注册进系统广播的Intent, automatically starting the target application if it is not already running. 将自动运行目标程序如果程序还没有启动的话。 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 receiver called 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. 说明:
For normal timing operations (ticks, timeouts, etc) it is easier and much more efficient to use 对于大多数定时操作(提醒,超时等)应用Handler将更简单和高效。 You do not instantiate this class directly; instead, retrieve it through 你不需要实例化它的对象,只需要通过Context.getSystemService(Context.ALARM_SERVICE)获取。 英文太菜了,意识还是很模糊,需要加强英语啊,多多阅读英文文档。 当设备在休眠中,注册的闹钟将会保留(如果时间到了将会看情况唤醒设备),但是如果闹钟关掉了 或者闹钟重启了讲会清除前面的设定。
Alarm Manager 将保持CPU激活状态到闹钟广播的接收者的onReceive() 方法运行。
这将可以保证手机不会休眠除非你终结广播事件的处理。
onReceive()返回一次,Alarm Manager就会释放唤醒锁。
这就意味着你的手机在某种情况下一沉睡,你的 onReceive() 方法将结束,
如果闹钟广播的接收者,调用了
Context.startService(),你的手机将可能在请求的服务运行之前 就睡死。 为了防止上述情况的发生,你的广播接收器和服务需要实现独立的设备唤醒机制,确保你的手机可以 继续运行除非服务已经生效。
Alarm Manager是为了应用在这中情况下的,当你需要让你的程序在某个特定的时间执行,甚 至你的程序并没有运行的时候。
|
||||
Android英文文档翻译系列(1)——AlarmManager的更多相关文章
- Android英文文档翻译系列(6)——LocalBroadcastManager
public class LocalBroadcastManager extends Object java.lang.Object ↳ android.support.v4.content.L ...
- Android英文文档翻译系列(5)——VPNService
API14位于android.net.VpnService 类概述|Class OverviewVpnService is a base class for applications to ext ...
- Android英文文档翻译系列(4)——PopupWindow
public class PopupWindow extends Object //直接继承至Object java.lang.Object ↳ android.widget.PopupWindow ...
- Android英文文档翻译系列(3)——AsyncTask
AsyncTask——异步任务 个人认为这是翻译比较好的一次.. Class Overview//类概述 AsyncTask enables proper and easy use of th ...
- Android英文文档翻译系列(2)——HandlerThread
public class HandlerThread extends Thread Class Overview Handy class for starting a new threa ...
- Android进阶——多线程系列之Thread、Runnable、Callable、Future、FutureTask
多线程一直是初学者最抵触的东西,如果你想进阶的话,那必须闯过这道难关,特别是多线程中Thread.Runnable.Callable.Future.FutureTask这几个类往往是初学者容易搞混的. ...
- Android提升篇系列:Activity recreate(Activity 重新创建/自我恢复)机制(一)
注:本文中的recreate是指当内存不足时,Activity被回收,但再次来到此Activity时,系统重新恢复的过程.例如:当Activity A到Activity B时,如果内存不足,A被回收, ...
- Android控件系列之RadioButton&RadioGroup(转)
学习目的: 1.掌握在Android中如何建立RadioGroup和RadioButton 2.掌握RadioGroup的常用属性 3.理解RadioButton和CheckBox的区别 4.掌握Ra ...
- Android网络编程系列 一 TCP/IP协议族
在学习和使用Android网路编程时,我们接触的仅仅是上层协议和接口如Apache的httpclient或者Android自带的httpURlconnection等等.对于这些接口的底层实现我们也有必 ...
随机推荐
- linux性能评估与分析工具
linux是一个开源系统,其内核负责管理系统的进程,内存,设备驱动程序,文件和网络系统, 决定着系统的性能和稳定性.由于内核源码很容易获取,任何人都可以将自己认为优秀的代码 加入到其中.linux默认 ...
- Android——ArrayList 、LinkList、List 区别 & 迭代器iterator的使用 & HashMap、Hashtable、LinkedHashMap、TreeMap
ArrayList .LinkList.List 区别 & 迭代器iterator的使用 & HashMap.Hashtable.LinkedHashMap.TreeMap 一.几个 ...
- 工作队列workqueue应用
工作队列是另一种将工作推后执行的形式,它可以把工作交给一个内核线程去执行,这个下半部是在进程上下文中执行的,因此,它可以重新调度还有睡眠. 区分使用软中断/tasklet还是工作队列比较简单,如果推后 ...
- iscsi线缆
- Phalcon的MVC框架解析
1. mvc/simple从最简单的入手吧. 把一些能及时说明白的东西写在注释里了,需要扩展的知识列在下面. public/index.php <?php $loader = new \Phal ...
- DataGridView使用技巧三:不显示最下面的新行、判断新增行
一.DataGridView不显示下面的新行 通常DataGridView的最下面一行是用户新追加的行(行头显示*).如果不想让用户新追加行即不想显示该新行,可以将DataGridView对象的All ...
- Log4j,Log4j2,logback,slf4j日志学习
日志学习笔记 Log4j Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.数据库等:我们也可以控制每一条日志的输出格式:通过定义每一条 ...
- 一段有用的javascript加密解密
今天在做一个老项目时,遇到一个需求,在javascript将url中的参数加密解密,从网上找发现了这段有用的代码: <SCRIPT LANGUAGE="JavaScript" ...
- Firefox 在LR录制过程中添加例外的问题解决方法
用lr调火狐打开网页 会报证书安全问题 证书安全提示目的是告诉你这个服务器使用的证书可能不安全,要不要信任,你自己决定,不信任就不能访问.为什么会报证书安全,因为浏览器没添加该证书.或者由于性能工具 ...
- 在 C++ 程序中只使用 const 常量而不使用宏常量
在 C++ 程序中只使用 const 常量而不使用宏常量,即 const 常量完 全取代宏常量. #include <iostream> /* run this program using ...