android - Screen_Off does not work in Application Level -


screen_off not work in application level ,although working on activity level.

my problem,when screen goes off,it must go login screen,below code ,successfully go login screen cause me unregistered receive broadcast

what have did

if l in menifesty level,screen off broadcast not fire,

manifest level

          <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 in activity level,then 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)) {                 // whatever need 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)) {                 // , whatever need here              }       } 

}

the screen_off broadcast protected broadcast, , receive if register dynamically through java code in service or activity or receiver. registering in manifest doesn't work broadcast.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -