Hi everyone, I'm developing a Kiosk App.
I set the app to go in Immersive Mode, however it is still possible for the user to show the android navigation and status bars… since it must be a kiosk app I do not want to have any android UI in it... is it possible to permanently hide the navigation and status bar while executing my app?
However, you can gain more control over the consequence of the user swiping to get out of immersive.
Using the example in Immersive Mode
In Main add this
B4X:
'In Process_Globals add
' Private lostImmersion As Boolean
Sub Activity_Touch(action As Int, X As Float, Y As Float)
If action = 1 And lostImmersion = True Then Swipe
If lostImmersion Then Return
If action = 2 And Y < 100 Or Y > Activity.Height - 100 Then lostImmersion = True
End Sub
Sub Swipe
B4XPages.MainPage.Swipe
lostImmersion = False
End Sub
In B4XMainPage add
B4X:
Public Sub Swipe
Dim sf As Object = xui.Msgbox2Async("Leave App?", "Warning", "Yes", "", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
ExitApplication
End If
End Sub
By the time the user responds, the Activity is back in immersive!
And the principle of User control is maintained.
However, you can gain more control over the consequence of the user swiping to get out of immersive.
Using the example in Immersive Mode
In Main add this
B4X:
'In Process_Globals add
' Private lostImmersion As Boolean
Sub Activity_Touch(action As Int, X As Float, Y As Float)
If action = 1 And lostImmersion = True Then Swipe
If lostImmersion Then Return
If action = 2 And Y < 100 Or Y > Activity.Height - 100 Then lostImmersion = True
End Sub
Sub Swipe
B4XPages.MainPage.Swipe
lostImmersion = False
End Sub
In B4XMainPage add
B4X:
Public Sub Swipe
Dim sf As Object = xui.Msgbox2Async("Leave App?", "Warning", "Yes", "", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
ExitApplication
End If
End Sub
By the time the user responds, the Activity is back in immersive!
And the principle of User control is maintained.
Yes that's what this does. Start with the Immersion Example Immersive Mode. Modify as I showed.
It starts in immersive mode.
When the user swipes (top or bottom), it detects that and intercedes with a message.
That message could be anything. For example "don't do that" (not recommended) or what I suggested: an option to exit the App (since it is an immersive only App).
You'll see that the immersive mode is back by the time the user replies.
I already tried... the immersive mode works (I followed the tutorial I linked), but when I Swipe Up the navigation bar and status bar are temporary showed anyway and the same happens with your example, even if the msgbox is shown. (see attached image)
Status bar seems to be gone only because there is a MsgBox showed... but I cannot use a MsgBox
I already prevent the user to exit from the application by putting it in KIOSK MODE. The goal is not this, but is to NOT show any type of bar of Android, neither when swiping up, nothing must happen.
Never permanently hide system bars on personal devices. You cannot permanently hide system bars in your app unless for an Android Enterprise deployment, so your designs should account for them to provide the optimal experience. Read more about designing for system bars.
For those still interested, there here is another fairly innocuous message that works to keep the App immersive.
Replace the Swipe sub in attachment #5 with
B4X:
Public Sub Swipe
Dim jo As JavaObject = xui.Msgbox2Async("Please Wait", "", "", "", "", Null)
Sleep(800)
jo.RunMethod("cancel", Null)
End Sub
Or even
B4X:
Public Sub Swipe
Dim jo As JavaObject = xui.Msgbox2Async("Not a valid swipe", "", "", "", "", Null)
Sleep(200)
jo.RunMethod("cancel", Null)
End Sub
Just being creative. If the theme color of MsgboxAsync is set to transparent, you can (untested) do this.
The only thing you'll see is a very brief flash of the navigation bar before it disappears.
B4X:
Public Sub Swipe
Dim jo As JavaObject = xui.Msgbox2Async("", "", "", "", "", Null)
Sleep(10)
jo.RunMethod("cancel", Null)
End Sub