문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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...).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top