سؤال

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