Java Question Bypassing lock screen

gorelshv

Member
Licensed User
Longtime User
Hi.
I need a way to bypass the lockscreen and show the app.
I've tried using WindowManager and setting a flag - "SHOW_WHEN_LOCKED" in a custom library but obviously I'm doing something wrong.

here is the code I've tried to use:

B4X:
   public void Unlock (final BA ba){
      Window layoutparams = ba.activity.getWindow();
      layoutparams.setFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);    
   }

When I run it I get a null reference exception...

What am I doing wrong?

Thanks in advance.
 

gorelshv

Member
Licensed User
Longtime User
Have you declared your class with @ActivityObject? Otherwise ba.activity will be null.

Thank you! It worked!
But now I have another problem. As I wake up the device and show my activity, I also want to run Voice Recognition. Problem is, as soon as VR shows the activity disappears and so is the little VR window, and the lock screen shows again. Without VR, my activity stays infront, as it should be. Any suggestions?
 

gorelshv

Member
Licensed User
Longtime User
That's OK, thanks for helping. I've subscribed to this thread just in case someone comes up with a solution.
 
Top