diff --git a/samples/ApiDemos/res/layout/alarm_controller.xml b/samples/ApiDemos/res/layout/alarm_controller.xml
index 0a9d00c1d..e3f18128e 100644
--- a/samples/ApiDemos/res/layout/alarm_controller.xml
+++ b/samples/ApiDemos/res/layout/alarm_controller.xml
@@ -33,6 +33,12 @@
+
+
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 2a7d639d9..288e4774d 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -348,6 +348,7 @@
This demonstrates how to schedule and handle
one-shot and repeating alarms.
One Shot Alarm
+ One Shot While-Idle Alarm
Start Repeating Alarm
Stop Repeating Alarm
One-shot alarm will go off in 30 seconds based on
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/AlarmController.java b/samples/ApiDemos/src/com/example/android/apis/app/AlarmController.java
index 2ba573564..8f2a4cb9c 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/AlarmController.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/AlarmController.java
@@ -63,6 +63,8 @@ App/Service/Alarm Controller
*/
+// Start with:
+// adb shell am start com.example.android.apis/.app.AlarmController
public class AlarmController extends Activity {
Toast mToast;
@@ -75,6 +77,8 @@ public class AlarmController extends Activity {
// Watch for button clicks.
Button button = (Button)findViewById(R.id.one_shot);
button.setOnClickListener(mOneShotListener);
+ button = (Button)findViewById(R.id.one_shot_while_idle);
+ button.setOnClickListener(mOneShotListener);
button = (Button)findViewById(R.id.start_repeating);
button.setOnClickListener(mStartRepeatingListener);
button = (Button)findViewById(R.id.stop_repeating);
@@ -99,7 +103,16 @@ public class AlarmController extends Activity {
// Schedule the alarm!
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
- am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
+
+ switch (v.getId()) {
+ case R.id.one_shot:
+ am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
+ break;
+ default:
+ am.setExactAndAllowWhileIdle(
+ AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
+ break;
+ }
// Tell the user about what we did.
if (mToast != null) {