Notice
Recent Posts
Recent Comments
Link
관리 메뉴

설.현.아빠

sleep mode에서 cpu, screen, keyboard 깨우기 본문

안드로이드/WakeLock

sleep mode에서 cpu, screen, keyboard 깨우기

설.현.아빠 2011. 5. 13. 11:44

 

 

 


 

 

package test.android.test;

 

import android.content.Context;

import android.os.PowerManager;

 

public class PushWakeLock {

       private static final String TAG = "wakelock";

       private static PowerManager.WakeLock mCpuWakeLock;

 

       static void acquireCpuWakeLock(Context context) {

             if (mCpuWakeLock != null) {

                    return;

             }

 

             PowerManager pm = (PowerManager) context

                           .getSystemService(Context.POWER_SERVICE);

 

             mCpuWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK

                           | PowerManager.ACQUIRE_CAUSES_WAKEUP

                           | PowerManager.ON_AFTER_RELEASE, TAG);

             mCpuWakeLock.acquire();

       }

      

       static void releaseCpuLock() {

             if(mCpuWakeLock != null) {

                    mCpuWakeLock.release();

                    mCpuWakeLock = null;

             }

       }

}

 

 


 

 

 

Flag Value CPU Screen Keyboard
PARTIAL_WAKE_LOCK On* Off Off
SCREEN_DIM_WAKE_LOCK On Dim Off
SCREEN_BRIGHT_WAKE_LOCK On Bright Off
FULL_WAKE_LOCK On Bright Bright


http://developer.android.com/reference/android/os/PowerManager.html




Comments