Back Button

briant1972

Member
Licensed User
Longtime User
Is there a way to disable the back button? I'm writing a kiosk program and am having trouble with the back button screwing up my bluetooth connection. When I press the home button, the app eventually returns and the bluetooth still works, but when I use the back button, it the app restarts but bluetooth is not working right. I have to disconnect and reconnect. Ultimately, the device only going needs to run the "kiosk" app so functionality of the back button is not important to me.
 

MDEnt

Member
Licensed User
Longtime User
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Select Msgbox2("Leave the adventure?", "", "Quit", "Restart", "Cancel", Null)
Case DialogResponse.NEGATIVE
Return True
Case DialogResponse.CANCEL
startButton_Click
Return True
Case DialogResponse.POSITIVE
quitandsave
End Select
End If
End Sub


Expanding on the disable back key in this thread, is there a way to disable the back key once this Msgbox2 has appeared - forcing only the options of Quit, Restart, or Cancel. I've played with an Else in there (now removed) and can't seem to get it right.

Thanks!
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You should use this code:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
  If KeyCode = KeyCodes.KEYCODE_BACK Then 
    Select Msgbox2("Leave the adventure?", "", "Quit", "Restart", "Cancel", Null)
    Case DialogResponse.NEGATIVE
      Return True
    Case DialogResponse.CANCEL
      startButton_Click
      Return True
    Case DialogResponse.POSITIVE
      quitandsave
    End Select
  End If
[COLOR=red]  Return False
[/COLOR]End Sub
 
Upvote 0

MDEnt

Member
Licensed User
Longtime User
I've tried that, what it seems to do is not only return me to the activity module where the Keypress Sub sits, but also automatically throws me back to the prior activity module. So in other words, hitting the back key during the messagebox2 throws me back 2 "screens."
 
Upvote 0
Top