PowerManager.WakeLock isHeld - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PowerManager.WakeLock isHeld method.

This code example shows how to use the following methods:isHeld, release
    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(); 
9
CodeRank
This code example shows how to use the following methods:acquire, isHeld, release, setReferenceCounted
    if (cpuWakeLock == null) {
      PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
      if (pm != null) {
        cpuWakeLock =
            pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG);
        cpuWakeLock.setReferenceCounted(true);
      } 
    } 
    if (cpuWakeLock != null) { //May be null if pm is null
      if (awake) {
        cpuWakeLock.acquire();
        L.d(TAG, "Adquired CPU lock");
      } else if (cpuWakeLock.isHeld()) {
        cpuWakeLock.release();
        L.d(TAG, "Released CPU lock");
      } 
    } 
  } 
 
  /** WiFi lock unique instance. */ 
9
CodeRank
This code example shows how to use the following methods:isHeld, release
    	Log.d(TAG, "Wakelock " + WAKELOCK + " aquired");
    } 
     
    public static void releaseWakelock() 
    { 
    	if ((m_saveWakelock != null) && (m_saveWakelock.isHeld()))
    	{ 
    		m_saveWakelock.release();
    		Log.d(TAG, "Wakelock " + WAKELOCK + " released");
    	} 
    } 
 
} 
8
CodeRank
This code example shows how to use the following methods:isHeld, release
                        mCamera.stopPreview();
                        mCamera.release();
                        mCamera = null;
                        surfaceCreated = false;
                    } 
                    if (mWakeLock.isHeld())
                        mWakeLock.release();
                } else { 
                    if (!surfaceCreated) {
                        int[] textures = new int[1];
                        // generate one texture pointer and bind it as an 
                        // external texture. 
                        GLES20.glGenTextures(1, textures, 0);
                        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                                textures[0]);
                        // No mip-mapping with camera source. 
                        GLES20.glTexParameterf(
                                GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                                GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
                        GLES20.glTexParameterf(
8
CodeRank
This code example shows how to use the following methods:acquire, isHeld, release, setReferenceCounted
    if (cpuWakeLock == null) {
      PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
      if (pm != null) {
        cpuWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
            | PowerManager.ON_AFTER_RELEASE, TAG);
        cpuWakeLock.setReferenceCounted(true);
      } 
 
    } 
    if (cpuWakeLock != null) { //May be null if pm is null
      if (awake) {
        cpuWakeLock.acquire();
        L.d(TAG, "Adquired CPU lock");
      } else if (cpuWakeLock.isHeld()) {
        cpuWakeLock.release();
        L.d(TAG, "Released CPU lock");
      } 
    } 
  } 
 
7
CodeRank
This code example shows how to use the following methods:isHeld, release
        mWakeLock.acquire();
        Log.d(mTag, "Wake lock acquired");
    } 
 
    public void releaseWakeLock() { 
        if(mWakeLock != null && mWakeLock.isHeld()) {
            mWakeLock.release();
            Log.d(mTag, "Wake lock released");
        } 
    } 
} 
8
CodeRank
This code example shows how to use the following methods:isHeld, release
				startProbe(); 
			} catch( IOException e ) {
				Log.e( TAG, "onHandleIntent : error", e );
			} finally { 
				 
    			if( wakeLock.isHeld() ) {
    				wakeLock.release();
    			} 
				 
				Intent completeIntent = new Intent( ACTION_COMPLETE );
				completeIntent.putExtra( EXTRA_COMPLETE, "Frontends are being discovered" );
			 
				sendBroadcast( completeIntent );
			} 
		} 
		 
		Log.v( TAG, "onHandleIntent : exit" );
	} 
 
	// jmDns interface 
8
CodeRank
This code example shows how to use the following methods:isHeld, release
     * default state. Usually called before {@link Service#stopSelf()}. 
     * <p> 
     * Only call this while holding a {@link #sLock} lock. 
     */ 
    static void clearLocked() { 
        if (sWakeLock != null && sWakeLock.isHeld()) {
            if (LOGD) Log.d(TAG, "found held wakelock, so releasing");
            sWakeLock.release();
        } 
        sWakeLock = null;
         
        sUpdateRequested = false;
        sUpdateRunning = false;
         
        sAppWidgetIds.clear();
        sChangedEventIds.clear();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:isHeld, release
    } 
 
    public static void releaseWakelock() 
    { 
    	Log.d(TAG, "releaseWakelock called");
    	if ((screen_on_wakelock != null) && (screen_on_wakelock.isHeld()))
    	{ 
    		screen_on_wakelock.release();
    		screen_on_wakelock = null;
    		Log.d(TAG, "Wakelock " + WAKELOCK + " released");
    	} 
    } 
 
    public static void releaseWifilock() 
    { 
    	Log.d(TAG, "releaseWifilock called");
    	if ((screen_on_wifilock != null) && (screen_on_wifilock.isHeld()))
    	{ 
    		screen_on_wifilock.release();
    		Log.d(TAG, "Wifilock " + WIFILOCK + " released");
7
CodeRank
This code example shows how to use the following methods:isHeld, release
	private static final String TAG = "ManageWakeLocks";
	private static final String POWER_SERVICE = Context.POWER_SERVICE;
	private static WakeLock sWakeLock;
	private static boolean sScreenOn = true;
	static boolean hasLock() { 
		return (sWakeLock != null) && (sWakeLock.isHeld());
	} 
	static void acquire(Context context) {
		if (hasLock()) { 
			sWakeLock.release();
		} 
		if (!sScreenOn) {
			if (sWakeLock == null) {
				sWakeLock = ((PowerManager) context.getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
			} 
			sWakeLock.acquire();
		} 
	} 
	static void release() { 
		if (hasLock()) { 

7
CodeRank

Related PowerManager.WakeLock isHeld Questions & Answers:

isHeld Method Overview
Returns true if the wake lock has been acquired but not yet released.
See Code Examples for other Android PowerManager.WakeLock Methods: