Reputation: 311
To keep a Wear OS app always visible I have been using
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
Unfortunately if the watch face is accidentally covered the app still moves to Ambient Mode
Ideally I want to disable AmbientMode altogether but can see no means of achieving this.
Instead the documentation indicates keeping the display on requires the app to monitor entry and exit of ambient mode. Once in Ambient Mode it is recommended the screen is updated less frequently using a repeating alarm. It all appears overly complex when all I want is the App to remain visible and updating at the same rate.
Hence my first thought was to implement the AmbientMode callback and if the watch tries to enter AmbientMode it is set back to Interactive Mode. Something like:
private class MyAmbientCallback : AmbientModeSupport.AmbientCallback() {
override fun onEnterAmbient(ambientDetails: Bundle?) {
// on entry to ambient mode set state back to Interactive Mode
ambientState = AmbientState.Interactive
}
}
Unfortunately this does not appear to be supported
So can anyone suggest how to disable AmbientMode or set the App back to InteractiveMode if it is (accidentally) placed into AmbientMode?
Upvotes: 1
Views: 1104
Reputation: 199825
There's no way to force the device to never go into Ambient Mode as that is absolutely critical to having any reasonable battery life on a Wear OS device.
By supporting Ambient Mode, your app can continue to run and can continue to update your screen until the user chooses to interact with their watch again (i.e., raise their wrist, etc. based on the user's preferences), which would move your app back into interactive mode.
Upvotes: 2