Android英文文檔翻譯系列(1)——AlarmManager,alarmmanager

來源:互聯網
上載者:User

Android英文文檔翻譯系列(1)——AlarmManager,alarmmanager

 原文:個人翻譯,水平有限,歡迎看官指正。                                                             public classAlarmManagerextends Object
java.lang.Object
   ↳ android.app.AlarmManager
Class Overview

This 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 that had been registered for it is broadcast by the system, 

當鬧鐘時間到了,註冊進系統廣播的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 Context.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. 

說明:

 

 

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

對於大多數定時操作(提醒,逾時等)應用Handler將更簡單和高效。

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

你不需要執行個體化它的對象,只需要通過Context.getSystemService(Context.ALARM_SERVICE)擷取。

 

 

 

英文太菜了,意識還是很模糊,需要加強英語啊,多多閱讀英文文檔。

 

                                                                                                                                     當裝置在休眠中,註冊的鬧鐘將會保留(如果時間到了將會看情況喚醒裝置),但是如果鬧鐘關掉了                                                                    或者鬧鐘重啟了講會清除前面的設定。                                                                                  Alarm Manager 將保持CPU啟用狀態到鬧鐘廣播的接收者的onReceive() 方法運行。                                                                   這將可以保證手機不會休眠除非你終結廣播事件的處理。                                                                                   onReceive()返回一次,Alarm Manager就會釋放喚醒鎖。                                                                  這就意味著你的手機在某種情況下一沉睡,你的 onReceive() 方法將結束,                                                                   如果鬧鐘廣播的接收者,調用了 Context.startService(),你的手機將可能在請求的服務運行之前                                                                    就睡死。                                                                  為了防止上述情況的發生,你的廣播接收器和服務需要實現獨立的裝置喚醒機制,確保你的手機可以                                                                       繼續運行除非服務已經生效。                                                                             Alarm Manager是為了應用在這中情況下的,當你需要讓你的程式在某個特定的時間執行,甚                                                                       至你的程式並沒有啟動並執行時候。        

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.