Android Question Show Activity When Screen Locked

bixmatech

Member
Licensed User
Hi...
I use this code to let the alarm window show , even though the device locked or slept.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("alarm")
    SetShowWhenLocked("addFlags")
End Sub

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

With Samsung's devices, worked perfectly, but with Sony z ultra (5.0.2) not working.

I added this permission:
AddPermission(android.permission.WAKE_LOCK) (need it or not ?)

Note :
- The Activity will start from a service.
- The service working on time, But the window not starting until I manually unlock the screen.

Thank You ...
 
Top