I want to know how I can execute some action, or continue listening to sensor or battery change events when th开发者_如何学Pythone phone is locked. (When the phone is locked it stops listening to sensor changes.)
I've tried with wakelocks but I it doesn't work (maybe I'm using it wrong).
Any help would be appreciated.
I'd recommend using a service for that. They run in background even while the phone is locked.
Here is the reference along with some explanation on Android Services
Wakelocks are a pain in the neck. I recommend giving CommonsWare's WakefulIntentService a try.
精彩评论