am 20d95001: Sync sample prebuilts for lmp-mr1-ub-docs

* commit '20d9500115e9ded1dbcdfa808da603dae0e1b905':
  Sync sample prebuilts for lmp-mr1-ub-docs
This commit is contained in:
Trevor Johns
2015-05-12 21:57:57 +00:00
committed by Android Git Automerger
2 changed files with 13 additions and 2 deletions

View File

@@ -30,6 +30,12 @@
<!--If you want your app to run on pre-22, then set required to false -->
<uses-library android:name="com.google.android.wearable" android:required="false" />
<!--
To update the screen more than once per minute in ambient mode, developers should set
the launch mode for the activity to single instance. Otherwise, the AlarmManager launch
intent will open a new activity every time the Alarm is triggered rather than reusing
the same (already active) Activity.
-->
<activity android:name="com.example.android.wearable.wear.alwayson.MainActivity"
android:label="@string/app_name"
android:launchMode="singleInstance"

View File

@@ -255,10 +255,15 @@ public class MainActivity extends WearableActivity {
long timeMs = System.currentTimeMillis();
if (isAmbient()) {
/** Prevents time drift while calculating trigger time (based on state). */
/** Calculate next trigger time (based on state). */
long delayMs = AMBIENT_INTERVAL_MS - (timeMs % AMBIENT_INTERVAL_MS);
long triggerTimeMs = timeMs + delayMs;
/**
* Note: Make sure you have set activity launchMode to singleInstance in the manifest.
* Otherwise, it is easy for the AlarmManager launch intent to open a new activity
* every time the Alarm is triggered rather than reusing this Activity.
*/
mAmbientStateAlarmManager.cancel(mAmbientStatePendingIntent);
mAmbientStateAlarmManager.setExact(
AlarmManager.RTC_WAKEUP,
@@ -266,7 +271,7 @@ public class MainActivity extends WearableActivity {
mAmbientStatePendingIntent);
} else {
/** Prevents time drift. */
/** Calculate next trigger time (based on state). */
long delayMs = ACTIVE_INTERVAL_MS - (timeMs % ACTIVE_INTERVAL_MS);
mActiveModeUpdateHandler.removeMessages(MSG_UPDATE_SCREEN);