Code example for PowerManager.WakeLock

Methods: isHeld, release

0
    if (connectivityListener != null) {
      context.unregisterReceiver(connectivityListener);
      connectivityListener = null;
    } 
 
    if (this.wakeLock.isHeld())
      this.wakeLock.release();
  } 
 
  private void issueConnectivityChange() { 
    Intent intent = new Intent(context, SendReceiveService.class);
    intent.setAction(getConnectivityAction());
    context.startService(intent);
  } 
 
  private class ConnectivityListener extends BroadcastReceiver {
    @Override 
    public void onReceive(Context context, Intent intent) {
      Log.w("MmsService", "Dispatching connectivity change...");
      issueConnectivityChange();