android - Activity not shown through LockScreen -
i trying show activity through lockscreen. second 1 in app, first 1 works without problem. using wakelock :
powermanager pm = (powermanager)getsystemservice(context.power_service); //mwakelock = pm.newwakelock(powermanager.partial_wake_lock, tag); mwakelock = pm.newwakelock(powermanager.partial_wake_lock, tag); mwakelock.acquire();
and using expected code within activity
"getwindow().addflags(windowmanager.layoutparams.flag_dismiss_keyguard | windowmanager.layoutparams.flag_turn_screen_on | windowmanager.layoutparams.flag_keep_screen_on);
i tried option :
windowmanager.layoutparams lp = getwindow().getattributes(); lp.flags |= windowmanager.layoutparams.flag_show_when_locked; lp.flags |= windowmanager.layoutparams.flag_dismiss_keyguard; lp.flags |= windowmanager.layoutparams.flag_turn_screen_on; lp.flags |= windowmanager.layoutparams.flag_keep_screen_on; getwindow().setattributes(lp);
the big difference between 2 activities when shown. first 1 (the 1 thats's working) reacts on android.provider.telephony.sms_received broadcast, whilst second 1 on intent.action_power_connected broadcast.
why wouldn't second 1 work ? lockscreen not removed show activity, if swipe lockscreen away activity showing right beneath it. might plugging power in not interceptable ?
/edit :
i did discover difference between 2 activities : 1 not work has theme based on dialog theme.
<style name="themewithcorners" parent="android:theme.holo.light.dialog">
if remove works fine, question how dialog-theme based activity behave in same manner ???
/edit2: after more googling , searching found piece of code works :
keyguardmanager keymgr = (keyguardmanager) getsystemservice(keyguard_service); keyguardmanager.keyguardlock keylock = keymgr.newkeyguardlock(tag); keylock.disablekeyguard();
the bad thing newkeyguardlock() method has been deprecated. might not work anymore in future releases (tested on 4.1.2). if knows right way accompish same feat ?
Comments
Post a Comment