Android Question Prevent closing the app (SOLVED)

Cadenzo

Active Member
Licensed User
Longtime User
I want the kids only can use the (B4Xpage) app I started, not using the home button and select other apps. I see that it is not possible to hide the softkeys.
The older kiosk-solution seems not to work because of Services starting apps are not allowed in newer Androids.
The newer kiosk-solution is not good for my needs, because I just want a "kiosk-mode" in that moment, I give the app to the kids.

For now my "solution" is hiding the softkeys with a tape 😄 But would be glad to have some more flexible ways.
 
Solution
B4X:
Sub Activity_Resume
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim activityManager As JavaObject = ctxt.RunMethod("getSystemService", Array("activity"))
    Dim LOCK_TASK_MODE_PINNED As Int = 2
    If activityManager.RunMethod("getLockTaskModeState", Null) <> LOCK_TASK_MODE_PINNED Then
        Dim joActivity As JavaObject
        joActivity.InitializeContext
        joActivity.RunMethod("startLockTask",Null)
    End If
End Sub

jkhazraji

Active Member
Licensed User
Longtime User
B4X:
Sub Activity_Resume
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim activityManager As JavaObject = ctxt.RunMethod("getSystemService", Array("activity"))
    Dim LOCK_TASK_MODE_PINNED As Int = 2
    If activityManager.RunMethod("getLockTaskModeState", Null) <> LOCK_TASK_MODE_PINNED Then
        Dim joActivity As JavaObject
        joActivity.InitializeContext
        joActivity.RunMethod("startLockTask",Null)
    End If
End Sub
 
Upvote 2
Solution

jkhazraji

Active Member
Licensed User
Longtime User
You are welcome,
Thanks just mark it as the correct answer please.
 
Upvote 0
Top