I have a Service that listens to network connectivity changes using the ConnectivityManager.CONNECTIVITY_ACTION intent filter. Should I acquire a partial cpu lock at the beginning of my onReceive method to process it?
Asked
Active
Viewed 963 times
1 Answers
1
you don't need to hold a wake lock for the broadcast receiver itself, android will do that for you.
But if you need to do anything long lasting, you will need to spawn a new service inside onReceive, at which time you should acquire a wake lock on the service.
also look at the documentation to make sure you only hold locks to system resources you really need (mostly just cpu) http://developer.android.com/reference/android/os/PowerManager.html

Ashwin Neurgaonkar
- 26
- 2
-
"you don't need to hold a wake lock for the broadcast receiver itself, android will do that for you" : Are you sure `ConnectivityManager.CONNECTIVITY_ACTION` will wake the receiver ? see : [BroadcastReceiver behavior when phone is asleep](http://stackoverflow.com/questions/16254420/broadcastreceiver-behavior-when-phone-is-asleep) – Mr_and_Mrs_D Apr 28 '13 at 21:12