본문 바로가기

Programming/android

screen on / off

안드로이드 화면 꺼짐 방지 (Screen on)

1. layout에서, android:keepScreenOn="true"의 속성을 준다.
 
사용예 :

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:keepScreenOn="true">

 

2. 자바 코드에서, 다음과 같은 코드를 추가한다. 


사용예 : 

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);


3. View에서 아무곳에서나 다음 메소드를 호출한다.

setKeepScreenOn(true);

 

안드로이드 화면 꺼짐 요청 (Screen off)
  

1. 코드에서 다음을 요청합니다.
 

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); 

wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DoNotDimScreen"); 



2. 매니페스트에서, 다음의 권한을 줍니다.
 

<uses-permission android:name="android.permission.WAKE_LOCK" /> 

 

'Programming > android' 카테고리의 다른 글

sd카드에 database 저장하기.  (0) 2011.08.18
[VideoView] 로컬 비디오파일 설정  (0) 2011.08.04
color를 xml로 사용하기.  (1) 2011.06.24
나인패치  (3) 2011.06.24
스크롤상태를 확인가능한 ScrollView  (13) 2011.06.21