Android onResume not called after onNewIntent -


i have broadcastreceiver should launch activity:

@override public void onreceive(context context, intent intent) {     if (wakelock == null)     {         powermanager pm = (powermanager) applicationscreen.instance.getapplicationcontext()                 .getsystemservice(context.power_service);         wakelock = pm.newwakelock(powermanager.partial_wake_lock, tag);     }     if (!wakelock.isheld())     {         wakelock.acquire();     }      try     {             if (applicationscreen.instance != null) {                 intent dialogintent = new intent(context, mainscreen.class);                 dialogintent.addflags(intent.flag_from_background | intent.flag_activity_reorder_to_front | intent.flag_activity_single_top);                 applicationscreen.instance.startactivity(dialogintent);             } else {                 intent dialogintent = new intent(context, mainscreen.class);                 dialogintent.addflags(intent.flag_from_background | intent.flag_activity_reorder_to_front | intent.flag_activity_new_task | intent.flag_activity_single_top);                 context.startactivity(dialogintent);             }      } catch (nullpointerexception e)     {     } } 

my mainscreen is:

@override public void onresume() {     log.e("tag", "onresume");     super.onresume(); }  @override protected void onnewintent(intent intent) {     super.onnewintent(intent);     // getintent() should return recent     setintent(intent);     log.e("tag", "onnewintent"); } 

onresume never called after onnewintent. expect that, if device go sleep, broadcastreceiver should wake , launch mainscreen. should tell, mainscreen extends applicationscreen. , applicationscreen extends activity.

edit:

device doesn't wake up. screen stays off.

the working solution me use decrepated powermanager.screen_bright_wake_lock when onnewintent() called.

int screen_bright_wake_lock = 10;    powermanager lpm = (powermanager) getsystemservice(context.power_service); wakelock lwl = lpm.newwakelock(screen_bright_wake_lock | powermanager.acquire_causes_wakeup); lwl.acquire(1000);   

this trigger onresume if activity stopped pressing power button. should use recommended windowmanager flags flag_turn_screen_on , flag_keep_screen_on.


Comments