Unlock password locked screen?

Discussion in 'Android Questions' started by MiniDemonic, Feb 10, 2012.

  1. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Hello Erel,

    No it does not work on my phone (Swipe keyguard, so no password). It works fine on the emulator, version less than Jelly Bean, reason why I asked.

    Thanks a lot
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    I will check it.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Tested it with Android 4.3 and it work fine.
    - The activity is visible.
    - I press on the power button and the screen turns off.
    - After a couple of seconds I press on the power button. The lock screen doesn't appear.
     
  4. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Erel,

    Thanks for testing. I did not mentionate this way works of course. I try to unlock via a service (sample project attached) and this works on the emulator.
    Could you please let me know what I do wrong.


    Main activity
    Code:
    Sub Process_Globals


    End Sub

    Sub Globals
        
    Dim Button1 As Button
        
    Dim Button2 As Button
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("test")
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)
        
    If UserClosed AND Not(IsPaused(unlock)) Then
            
    StopService(unlock)   
        
    End If   
       
    End Sub


    Sub SetShowWhenLocked
       
    Dim r As Reflector
       r.Target = r.GetActivity
       r.Target = r.RunMethod(
    "getWindow")
       r.RunMethod2(
    "addFlags"6815872"java.lang.int")
    End Sub

    Sub Button1_Click ' unlock by activity
        SetShowWhenLocked
    End Sub

    Sub Button2_Click ' unlock by service
        StartServiceAt(unlock,DateTime.Now+20*1000,True)
    End Sub
    Service
    Code:
    Sub Process_Globals
        
    Dim T1 As Timer
        
    Dim WS As PhoneWakeState
       

    End Sub
    Sub Service_Create
        T1.Initialize(
    "T1",5*1000' delay to see the unlock

    End Sub

    Sub Service_Start (StartingIntent As Intent)
        T1.Enabled=
    True
        WS.KeepAlive(
    True)
        
    If IsPaused(Main) Then
            
    StartActivity("Main")
        
    End If
    End Sub

    Sub Service_Destroy
        WS.ReleaseKeepAlive
    End Sub


    Sub T1_Tick
        
    CallSub(Main,"SetShowWhenLocked")
        T1.Enabled=
    False
    End Sub
     

    Attached Files:

    lte5000 likes this.
  5. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Fixed by calling SetShowWhenLocked in Activity_Resume

    Code:
    Sub Activity_Resume
        SetShowWhenLocked
    End Sub
     
    moster67, JordiCP and lte5000 like this.
  6. selad

    selad New Member Licensed User

    Where and when should I call this sub?
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    In Activity_Create.
     
  8. selad

    selad New Member Licensed User

    Thank, also in Activity_Resume?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    According to post #25 it should go in Activity_Resume. I don't remember whether it is important or not.
     
  10. Mark Hollingworth

    Mark Hollingworth Member Licensed User

    Hi Erel,

    I know this is a bit of an old post but I have just used the SetShowWhenLocked code, it seems to work fine when running in debug mode but when I install a release version to my device it throws an error message box with the following text:

    An Error has occurred in sub:
    java.lang.Exception: Sub was not found
    continue?

    It looks like the code still works as the activity shows ontop of the lock screen so not sure what is going on, any ideas?

    My device is using Android Version 5.0.2 and I am using v5.00 of b4a.
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Are you using USB debug mode? If yes then you should see the full error message in the logs.
     
  12. Mark Hollingworth

    Mark Hollingworth Member Licensed User

    Hi Erel,

    Thanks for the reply, I am now using USB debugging correctly and this is what coming up in the log:

    ** Service (connectionlistener) Start **
    ** Activity (main) Create, isFirst = true **
    ** Activity (main) Resume **
    ** Service (wifimanagerservice) Create **
    ** Service (wifimanagerservice) Start **
    ** Activity (main) Pause, UserClosed = false **
    ** Activity (main) Resume **
    ** Activity (main) Pause, UserClosed = false **
    ** Activity (main) Resume **
    ** Service (managerservice) Create **
    ** Service (managerservice) Start **
    Bundle[{admin_intent=Intent { act=android.app.action.ACTION_PASSWORD_FAILED flg=0x10 cmp=co.uk.newappdevelopment.SmartWifiSwitcher/anywheresoftware.b4a.objects.AdminManager$AdminReceiver }}]
    failed login
    ** Activity (main) Pause, UserClosed = false **
    ** Activity (securityscreen) Create, isFirst = true **
    Bring screen to front
    Done - Bring screen to front
    ** Activity (securityscreen) Resume **
    java.lang.Exception: Sub was not found.
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:193)
    at anywheresoftware.b4a.keywords.Common$5.run(Common.java:981)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6141)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
    java.lang.Exception: Sub was not found.
    ** Service (connectionlistener) Start **
     
  13. Mark Hollingworth

    Mark Hollingworth Member Licensed User

    ok so after a bit more digging and adding in some more logging I think I have found where the error is coming from (and I probably should of added this info in the first post)

    After a password is enter incorrectly my activity is started and it enabled the front camera and takes a picture using the CameraEX library if I remove the code that enables the camera and take the picture I no longer have any errors so it looks like the culprit is in the CameraEx Lib and not the code that displays the activity in front of the lock screen. :oops:

    I will create a new thread for this question as its not related, the SetShowWhenLocked code still works fine :)

    Thanks for the help
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice