Timothy
Timothy

Reputation: 618

Stop wear os app from going to the background

I'm developing a wear os app and have the following issue:

When the watch goes dark (either by timeout or by the palm gesture) and I turn my wrist or tap the watch, I'm back at the home screen with my watch face.

What I would like instead, is that I'm back in my app where I left off. I don't need the app to stay on all the time, nor do I collect any continious data. So it's okay that the screen goes black and "pauses" the app, I just want to get back to where I was before the screen went dark.

I can manually go to the recent apps and select my app. Then I'm back where I left off and everything is working as expected.

What's really confusing to me, is how I should change my code so that either my app never goes to the background or comes back to the foreground when my watch is turned on again.

I have tried the FLAG_KEEP_SCREEN_ON and this works as a workaround. The watch will never time out but the palm gesture will still turn the screen off and I have the same issues as described above. And It's unnecessarily consuming battery power.

I have also tried a broadcast receiver. But I couldn't get it to work, the Intent.ACTION_SCREEN_ON was never triggered. I assume because my app was in the background.

I have also read about always on apps: https://developer.android.com/training/wearables/always-on. But I'm not sure that this is also the best approach in my case? Since I don't need the app to always be on. But I thought about implementing the always on feature and simply don't set any content when it goes itno ambient mode.

What's the best approach for my use case?

Upvotes: 0

Views: 89

Answers (0)

Related Questions