Question

I'm writing an app with alarm functionality, i.e. it will have to continue running while the device goes into standby. Apparently, this is not the case. How can I achieve that?

It would be even better if I could prevent the device from going into standby at all - can I do that?

Was it helpful?

Solution

Android applications can prevent the device from going into standby with a wake lock but this should be used only for short periods of time for specific tasks which require the user to look at the screen without touching it.

For any other long time purposes, you have to use the system AlarmManager to schedule future actions of your application.

Using a permanent wake lock would make your app a battery drainer.

OTHER TIPS

A service runs always, even in standby, so you should use it.

Preventing standby can be done with a wake lock. Be careful, there are only a few apps that should prevent standby (like games, video players...).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top