Skip to content

Latest commit

 

History

History
56 lines (36 loc) · 2.95 KB

README.md

File metadata and controls

56 lines (36 loc) · 2.95 KB

Android AlwaysOn Sample (Kotlin)

A basic sample showing how to support ambient mode for native Wear apps.

Introduction

The AmbientModeSupport class offers methods for supporting your native app staying on the screen when the Wear device enters ambient mode.

This example implements the AmbientCallbackProvider interface and provides behavior for onEnterAmbient, onUpdateAmbient, and onExitAmbient to allow the simple native Wear app to support ambient mode. In ambient mode, this app follows best practices by keeping most pixels black, avoiding large blocks of white pixels, using only black and white, and disabling anti-aliasing (following the design guidelines for Watch Faces).

In addition and most importantly, the app sleeps while in ambient mode for 10 seconds between any updates to conserve battery life (processor allowed to sleep). If you can hold off on updates for a full minute, you can avoid AlarmManager and just use onUpdateAmbient to save even more battery life.

As always, you will still want to apply the performance guidelines outlined in the Watch Face documentation to your app.

IMPORTANT NOTE

Most apps shouldn't use the always on/ambient mode APIs, as it drains battery life and the system already handles this for you.

That is, by default (without this API), the system will go into system ambient mode if the user hasn't interacted with the watch in a period of time, and if the user interacts again with the watch soon after that, the system will automatically bring up your app again in the same state it was before that point which covers most use cases.

Pre-requisites

  • Android SDK 30
  • Requires AC to be configured off adb emu power ac off

Screenshots

Screenshot Screenshot Screenshot Screenshot

Getting Started

This sample uses the Gradle build system. To build this project, use the "gradlew build" command or use "Import Project" in Android Studio.

Support

If you've found an error in this sample, please file an issue: https://github.com/android/wear-os-samples

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.