Screen_Off는 응용 프로그램 수준에서 작동하지 않지만 활동 수준에서 작동합니다. 화면이 꺼질 때Screen_Off가 응용 프로그램 수준에서 작동하지 않습니다.
내 문제, 그것은 코드 아래 화면 로그인으로 이동해야 성공적으로 나 등록되지 않은 내가 한 것을
방송
수신 원인 화면 로그인으로 이동하지만리터 경우에 할 Menifesty 수준, 오프 스크린 방송,
매니페스트 레벨
<receiver android:name="com.android.libray.ScreenReciver" android:enabled="true" >
<intent-filter>
<action android:name="android.intent.action.SCREEN_OFF"/>
<action android:name="android.intent.action.SCREEN_ON"/>
</intent-filter>
</receiver>
if i do in activity level,then it will fire screenReciver
IntentFilter filter =new IntentFilter(Intent.ACTION_SCREEN_OFF);
BroadcastReceiver mReceiver=new ScreenReciver();
registerReceiver(mReceiver, filter);
public class ScreenReciver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
// do whatever you need to do here
Intent myintent = new Intent(context,TimerClockActivity.class);
myintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
myintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myintent);
wasScreenOn = false;
Log.v("screenoff", "Logggoff");
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
// and do whatever you need to do here
}
}
}를 발생하지 않습니다
Application 클래스를 구현 했습니까? 응용 프로그램 클래스를 확장 해보십시오. – minhaz