user1803551
user1803551

Reputation: 13427

How to prevent an app from going to sleep using Gluon Mobile?

We are writing something similar to a navigation app, which can be either visual-based or sound-based. We are hitting a problem where the phone will enter sleep mode (might not be the correct technical term) after a while during the runtime of the application if the screen is not interacted with, causing it to both blank the screen and interrupt the LocationService of Attach.

Reproduction is simple: create any Gluon Mobile application, like the started demo one, open it and wait. The phone will enter sleep mode.

We would like to do the following:

  1. When visual mode is on, keep the screen lit and keep sending location updates without letting the phone stop these via some power saving mode / sleep. Some applications to this, like Google Maps, so this is not a special requirement.
  2. When only sound mode is on, the phone can turn off the screen to save on battery, but we still need the application running with location updates and the ability to give sound notification to the user.

I've looked into the LifecycleService and the BatteryService in Attach, but there is no functionality that matches what we need. Lifecycle allows to listen to changes in the lifecycle of the application, but not modify them (except for shutting down).

How can we fulfill the requirements? For now we are on Android only, but in the future we plan to expand to iOS as well.

Upvotes: 2

Views: 29

Answers (0)

Related Questions