From a34df8a2ba450b2c2ad83ccbbac30b80e2706bb2 Mon Sep 17 00:00:00 2001 From: Chris Tate <> Date: Thu, 2 Apr 2009 23:15:58 -0700 Subject: [PATCH] AI 144405: am: CL 144307 am: CL 144306 Fix SDK issue 1716562 - Broadcast mechanism documentation should be improved. Original author: ctate Merged from: //branches/cupcake/... Original author: android-build Automated import of CL 144405 --- core/java/android/app/AlarmManager.java | 11 ++++++++++ .../android/content/BroadcastReceiver.java | 22 +++++++++++++------ core/java/android/content/Context.java | 13 ++++++----- .../guide/topics/manifest/receiver-element.jd | 21 +++++++++++++----- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java index b4c0e314cfb62..53c79352d3f4a 100644 --- a/core/java/android/app/AlarmManager.java +++ b/core/java/android/app/AlarmManager.java @@ -29,6 +29,17 @@ import android.os.ServiceManager; * 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 {@link android.content.Context#startService 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 diff --git a/core/java/android/content/BroadcastReceiver.java b/core/java/android/content/BroadcastReceiver.java index a41627aa3ab4d..b391c57df5ee6 100644 --- a/core/java/android/content/BroadcastReceiver.java +++ b/core/java/android/content/BroadcastReceiver.java @@ -44,14 +44,14 @@ import android.util.Log; *