Sync sample prebuilts for lmp-mr1-ub-docs
Synced to //developers/samples/android commit 7e6f96a4bd8d07daf2f9e464dad32e7daa62999b Change-Id: I3c44d32aca1a5513f52e71f28d1848a055d03aab
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user