URL : http://stackoverflow.com/questions/10748861/how-to-change-screen-timeout-programmatically
It is simple to do.. You should learn to solve your problem from Android source code.
/**
* set screen off timeout
* @param screenOffTimeout int 0~6
*/
private void setTimeout(int screenOffTimeout) {
int time;
switch (screenOffTimeout) {
case 0:
time = 15000;
break;
case 1:
time = 30000;
break;
case 2:
time = 60000;
break;
case 3:
time = 120000;
break;
case 4:
time = 600000;
break;
case 5:
time = 1800000;
break;
default:
time = -1;
}
android.provider.Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_OFF_TIMEOUT, time);
}
if someone isnt working you may need the permissions
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
설정은 위와 같이 하면 되고,
가져오는 것은
android.provider.Settings.System.getInt(activity.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 0);
으로 하면 된다.
일반적으로 폰에서 설정>디스플레이 설정>화면 자동꺼짐 설정의
목록들은 Preference로 되어 있어서, Settings 앱에서 Provider라든지. Intent로 정보를 제공해 주지 않으면
공식적으로 알아낼 방법은 없다.
참고로 단위는 1/1000초 이다.
'Programming > Android Java' 카테고리의 다른 글
android Bluetooth LE programming(BLE) (0) | 2014.07.25 |
---|---|
How to prevent screen timeout in Android (0) | 2014.07.18 |
PowerManager 를 통해 안드로이드의 진정한 주인이 되어 봅시다. (0) | 2014.07.18 |
android-ibeacon-source-code-Jaalee-master/JaaleeService.java (0) | 2014.06.21 |
ContentResolver (0) | 2014.06.20 |