Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Example: 關於Android framwork的Power management




core/java/android/os/PowerManager.java 裡面的注解就大致說明了, 如何呼叫使用wake lock! 必須先newWakeLock(), 再acquire()使用, 最後要記得release()

* Get a wake lock at the level of the flags parameter. Call
* {@link WakeLock#acquire() acquire()} on the object to acquire the
* wake lock, and {@link WakeLock#release release()} when you are done.
* {@samplecode
*PowerManager pm = (PowerManager)mContext.getSystemService(
*PowerManager.WakeLock wl = pm.newWakeLock(
* | PowerManager.ON_AFTER_RELEASE,
* TAG);

* // …
* }

* @param flags Combination of flag values defining the requested behavior of the WakeLock.
* @param tag Your class name (or other tag) for debugging purposes.
* @see WakeLock#acquire()
* @see WakeLock#release()
public WakeLock newWakeLock(int flags, String tag)
if (tag == null) {
throw new NullPointerException(“tag is null in PowerManager.newWakeLock”);
return new WakeLock(flags, tag);