크리에이티브 커먼즈 라이선스
Creative Commons License

 

 

 


 

 

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




저작자 표시 비영리 변경 금지
신고

'안드로이드 > WakeLock' 카테고리의 다른 글

sleep mode에서 cpu, screen, keyboard 깨우기  (0) 2011.05.13
Posted by DoDo4989

댓글을 달아 주세요


티스토리 툴바