Reputation: 651
I want to know how I can execute some action, or continue listening to sensor or battery change events when the 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.
Upvotes: 4
Views: 713
Reputation: 5784
Wakelocks are a pain in the neck. I recommend giving CommonsWare's WakefulIntentService a try.
Upvotes: 1
Reputation: 39603
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
Upvotes: 2