PowerManager.WakeLock setReferenceCounted - 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 setReferenceCounted method.

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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setReferenceCounted
  public MmscProcessor(Context context) {
    this.context = context;
    PowerManager powerManager         = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
    this.connectivityManager          = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
    this.wakeLock                     = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MMS Connection");
    this.wakeLock.setReferenceCounted(false);
  } 
 
  protected String getApnInformation() {
    return connectivityManager.getNetworkInfo(TYPE_MOBILE_MMS).getExtraInfo();
  } 
 
  protected boolean isConnected() { 
    NetworkInfo info = connectivityManager.getNetworkInfo(TYPE_MOBILE_MMS);
 
    Log.w("MmsService", "NetworkInfo: " + info);
 
    if ((info == null) || (info.getType() != TYPE_MOBILE_MMS) || !info.isConnected())
      return false; 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:acquire, setReferenceCounted
 
		// create the new wakelock and put it into the map 
		final WakeLock newWakeLock = mgr.newWakeLock(flags, id.toString());
 
		// if this wakelock doesn't already exist, continue 
		locks.put(id, newWakeLock);
		// only one at a time? TODO 
		newWakeLock.setReferenceCounted(false);
 
		if (releaseAfterMs == 0) {
			newWakeLock.acquire();
		} else { 
			newWakeLock.acquire(releaseAfterMs);
		} 
	} 
 
	public static void release(String id) {
		final WakeLock wakeLock = locks.get(id);
		// if there is was a wakelock, release it. (it has to be held) 
		try { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setReferenceCounted
		if (lock == null) {
			PowerManager mgr = (PowerManager) context
					.getSystemService(Context.POWER_SERVICE);
 
			lock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "org.jtb.alogrec.lock");
			lock.setReferenceCounted(true);
		} 
		return lock;
	} 
 
	public static synchronized void acquire(Context context) {
		WakeLock wakeLock = getLock(context);
		if (!wakeLock.isHeld()) {
			wakeLock.acquire();
		} 
	} 
 
	public static synchronized void release() { 
		if (lock == null) {
			Log 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setReferenceCounted
 
	private static synchronized WakeLock getLock(Context context) {
		if (lockStatic == null) {
			PowerManager powerManager = getPowerManager(context);
			lockStatic = powerManager.newWakeLock(PARTIAL_WAKE_LOCK, LOCK_NAME_STATIC);
			lockStatic.setReferenceCounted(true);
		} 
 
		return (lockStatic);
	} 
 
	protected static PowerManager getPowerManager(Context context) {
		PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
		return powerManager;
	} 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setReferenceCounted
        if (lock == null) {
            PowerManager mgr = (PowerManager) context
                               .getSystemService(Context.POWER_SERVICE);
 
            lock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "vagner.android.CrashHandler.lock");
            lock.setReferenceCounted(true);
        } 
        return lock;
    } 
 
    public static synchronized void acquire(Context context) {
        WakeLock wakeLock = getLock(context);
        if (!wakeLock.isHeld()) {
            wakeLock.acquire();
        } 
    } 
 
    public static synchronized void release() { 
        if (lock != null) {
            if (lock.isHeld()) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setReferenceCounted
		if (lock == null) {
			PowerManager mgr = (PowerManager) context
					.getSystemService(Context.POWER_SERVICE);
 
			lock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "org.jtb.alogcat.lock");
			lock.setReferenceCounted(true);
		} 
		return lock;
	} 
 
	public static synchronized void acquire(Context context) {
		WakeLock wakeLock = getLock(context);
		if (!wakeLock.isHeld()) {
			wakeLock.acquire();
			Log.d("alogcat", "wake lock acquired");
		} 
	} 
 
	public static synchronized void release() { 
		if (lock == null) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setReferenceCounted
if(lockStatic==null){
PowerManager mgr= (PowerManager)c.getSystemService(Context.POWER_SERVICE);
 
lockStatic=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,LOCK_NAME_STATIC);
 
lockStatic.setReferenceCounted(true);
 
 
} 
 
return(lockStatic);
 
} 
 
public WakeReminderIntentService(String name){
super(name);
 
} 
 
@Override 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setReferenceCounted
 
    public HeadsetObserver(Context context) {
        mContext = context;
        PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
        mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "HeadsetObserver");
        mWakeLock.setReferenceCounted(false);
 
        startObserving(HEADSET_UEVENT_MATCH);
 
        init();  // set initial status 
    } 
 
    @Override 
    public void onUEvent(UEventObserver.UEvent event) {
        if (LOG) Log.v(TAG, "Headset UEVENT: " + event.toString());
 
        try { 
            update(event.get("SWITCH_NAME"), Integer.parseInt(event.get("SWITCH_STATE")));
        } catch (NumberFormatException e) {
            Log.e(TAG, "Could not parse switch state from event " + event);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related PowerManager.WakeLock setReferenceCounted Questions & Answers:

setReferenceCounted Method Overview
Sets whether this WakeLock is reference counted.
See Code Examples for other Android PowerManager.WakeLock Methods: