일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 구글
- 노개북
- 개발
- mime
- Eclipse
- gradle
- Android 4.1
- 악성코드
- Android
- 자바
- 코틀린
- KTS
- linux
- kotlin
- c
- 하버드
- ActiveMovieControl
- 리눅스
- 안드로이드
- build.gradle
- 탐지기법
- C++
- 안드로이드 개발
- java
- git
- ActiveX
- 보안
- 안철수
- OOM
- Today
- Total
꿈소년의 개발 이야기
Power Management 본문
java.lang.Object | |
↳ | android.os.PowerManager |
Class Overview
This class gives you control of the power state of the device.
Device battery life will be significantly affected by the use of this API. Do not acquire WakeLocks unless you really need them, use the minimum levels possible, and be sure to release it as soon as you can.
You can obtain an instance of this class by calling Context.getSystemService()
.
The primary API you'll use is newWakeLock()
. This will create a PowerManager.WakeLock
object. You can then use methods on this object to control the power state of the device. In practice it's quite simple:
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 flags are defined, with varying effects on system power. These flags are mutually exclusive - you may only specify one of them.
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 |
*If you hold a partial wakelock, the CPU will continue to run, irrespective of any timers and even after the user presses the power button. In all other wakelocks, the CPU will run, but the user can still put the device to sleep using the power button.
In addition, you can add two more flags, which affect behavior of the screen only. These flags have no effect when combined with aPARTIAL_WAKE_LOCK
.
Flag Value | Description |
---|---|
ACQUIRE_CAUSES_WAKEUP | 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. |
ON_AFTER_RELEASE | 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. |
'Android Development' 카테고리의 다른 글
[Android API] onConfigurationChanged (0) | 2010.10.08 |
---|---|
Service (0) | 2010.08.16 |
Activity & Task (0) | 2010.08.13 |
안드로이드 GG 성명 ㅋ 이것도 참 재미있다 (0) | 2010.07.19 |
[Android] Android TTS & Eye-Free Project (0) | 2010.07.09 |