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?
I have a Service that listens to network connectivity changes using the ConnectivityManager.CONNECTIVITY_ACTION intent
Share
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