Android Open Source - appservices-android-push-example Wake Locker






From Project

Back to project page appservices-android-push-example.

License

The source code is released under:

Apache License

If you think the Android project appservices-android-push-example listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ganyo.pushtest;
/*  w  w w.  ja v  a 2s  .c o m*/
import android.content.Context;
import android.os.PowerManager;

public abstract class WakeLocker {
  private static PowerManager.WakeLock wakeLock;

  public static void acquire(Context context) {
    if (wakeLock != null) wakeLock.release();

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK |
        PowerManager.ACQUIRE_CAUSES_WAKEUP |
        PowerManager.ON_AFTER_RELEASE, "WakeLock");
    wakeLock.acquire();
  }

  public static void release() {
    if (wakeLock != null) wakeLock.release(); wakeLock = null;
  }
}




Java Source Code List

com.ganyo.pushtest.AlertDialogManager.java
com.ganyo.pushtest.AppServices.java
com.ganyo.pushtest.GCMIntentService.java
com.ganyo.pushtest.MainActivity.java
com.ganyo.pushtest.Settings.java
com.ganyo.pushtest.Util.java
com.ganyo.pushtest.WakeLocker.java