How to prevent sleep in Android

I work with GPS in my application. When the phone goes into sleep mode, GPS data is not updated. I want the phone screen to wake up until my application is close. How can I prevent sleep in Android?

+6
android sleep
source share
2 answers

Use WakeLock . Keep in mind that using WakeLock will drain the battery for a long period of time, which your users may not appreciate.

+3
source share

I would try linking things related to GPS as a service in the background, so you don't need to keep the screen active.

0
source share

All Articles