dismiss screen lock problem

KZero

Active Member
Licensed User
Longtime User
B4X:
Sub SetShowWhenLocked
    Dim r As Reflector
    r.Target = r.GetActivity
    r.Target = r.RunMethod("getWindow")
    r.RunMethod2("addFlags", 6815872, "java.lang.int")
End Sub

i wanna use this code to dismiss screen lock

but everytime i try to call "SetShowWhenLocked" the app crashes

am i doing anything wrong ?
 

stevel05

Expert
Licensed User
Longtime User
What error do you get in the log?
 
Upvote 0

KZero

Active Member
Licensed User
Longtime User
What error do you get in the log?

B4X:
** Activity (main) Create, isFirst = true **


main_setshowwhenlocked (B4A line: 55)


r.Target = r.GetActivity
java.lang.NoSuchFieldError: anywheresoftware.b4a.BA.activityBA


   at anywheresoftware.b4a.agraham.reflection.Reflection.GetActivity(Reflection.java:638)
   at anywheresoftware.b4a.samples.httputils2.main._setshowwhenlocked(main.java:543)
   at anywheresoftware.b4a.samples.httputils2.main._activity_create(main.java:243)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at anywheresoftware.b4a.samples.httputils2.main.afterFirstLayout(main.java:89)
   at anywheresoftware.b4a.samples.httputils2.main.access$100(main.java:16)
   at anywheresoftware.b4a.samples.httputils2.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:605)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4340)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
   at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I've just tried your code it doesn't error in an activity for me. Are you running this in a service? Can you zip and post your project?
 
Upvote 0

KZero

Active Member
Licensed User
Longtime User
I've just tried your code it doesn't error in an activity for me. Are you running this in a service? Can you zip and post your project?

i tried the code in new project also same problem

i'm running it from Activity module also i tried it on 3 devices and emulator it always crash :(

file attached
 

Attachments

  • test.zip
    6 KB · Views: 208
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Strange, I can't get it to fail. What version of the reflection Library do you have?
 
Upvote 0
Top