开发者

How to prevent sleeping in Android

开发者 https://www.devze.com 2023-01-14 18:12 出处:网络
I \'m working with GPS in my application. When phone go to sleep, the GPS\'s data don\'t update. I want to stay phone screen wake up until my app will be close. How can I prevent sl开发者_C百科eeping

I 'm working with GPS in my application. When phone go to sleep, the GPS's data don't update. I want to stay phone screen wake up until my app will be close. How can I prevent sl开发者_C百科eeping in Android?


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


I'd try to have the GPS related stuff running as a service in the background so you don't have to keep the screen active.

0

精彩评论

暂无评论...
验证码 换一张
取 消