장치의 배터리 생명은 이 API를 사용함에 따라 상당한 영향을 받을 것이다. 정말로 필요하지 않는 한 acquire, PowerManager.WakeLock는 사용하지 말고, 가능한 가장 낮은 레벨을 사용하고 그리고 가능한 한 빨리 release하라.
너는 Context.getSystemService()를 호출함으로써 이 클래스의 인스턴스를 얻을수 있다.
주된 API는 newWakeLock()이다. 그것은 PowerManager.WakeLock 객체를 만들어 준다. 너는 wake lock 객체를 이용해서 장치의 전원상태를 제어하는 메소드들을 사용할 수 있다.
예)
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
wl.acquire();
// ..screen will stay on during this section..
wl.release();
The following wake lock levels are defined, with varying effects on system power.
그 다음으로 wake lock 레벨들은 시스템 전원에 변화하는 효과와 함께 정의된다. 이 레벨들은 상호 배타적이다. - 너는 오직 그것들 중 하나만 명시할지도 모른다.
*If you hold a partial wake lock, the CPU will continue to run, regardless of any display timeouts or the state of the screen and even after the user presses the power button. In all other wake locks, the CPU will run, but the user can still put the device to sleep using the power button.
덧붙혀, 너는 오직 화면의 행동에 영향을 주는 두개의 플래그를 추가할 수 있다. 그 플래그들은 PARTIAL_WAKE_LOCK와 같이 사용할때 효과를 얻지 못한다.
Normal wake locks don't actually turn on the illumination. Instead, they cause the illumination to remain on once it turns on (e.g. from user activity). This flag will force the screen and/or keyboard to turn on immediately, when the WakeLock is acquired. A typical use would be for notifications which are important for the user to see immediately.
If this flag is set, the user activity timer will be reset when the WakeLock is released, causing the illumination to remain on a bit longer. This can be used to reduce flicker if you are cycling between wake lock conditions.
Any application using a WakeLock must request the android.permission.WAKE_LOCK permission in an <uses-permission> element of the application's manifest.
This constant was deprecated in API level 17. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.
This constant was deprecated in API level 13. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.
This constant was deprecated in API level 17. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.