<intent-filter>
<action android:name="android.intent.action.SCREEN_OFF" />
<action android:name="android.intent.action.SCREEN_ON" />
</intent-filter>
Receiver 를 통해 화면의 off, on 방송을 수신할 수 있습니다.
Receiver 를 만들고
위와같은 인텐트필터를 Manifest 의 receiver 태그의 자식 태그로 등록한 후
해당 리시버의 onReceive 함수를 다음과 같이 오버라이드 하면
화면의 꺼짐/켜짐 이벤트 콜백을 받을 수 있습니다.
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_SCREEN_OFF) {
// 화면 꺼질 때
} else if(action.equals(Intent.ACTION_SCREEN_ON) {
// 화면 켜질 때
]
}
더 자세한 사항은 검색해보세요~