acidorus Member Licensed User Longtime User Oct 10, 2018 #1 how to intercept the CameBack and Home Button.
Semen Matusovskiy Well-Known Member Licensed User Oct 10, 2018 #2 WIth Back button all is simple - search by KeyCodes.KEYCODE_BACK and you will find example. Home button is busy by system. It's possible to declare an app as "launcher", but better not to do this. User expects default system actions. Upvote 0
WIth Back button all is simple - search by KeyCodes.KEYCODE_BACK and you will find example. Home button is busy by system. It's possible to declare an app as "launcher", but better not to do this. User expects default system actions.
Star-Dust Expert Licensed User Longtime User Oct 11, 2018 #3 Amarildo Lázaro said: how to intercept the CameBack Click to expand... Code: Copy Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event If KeyCode = KeyCodes.KEYCODE_BACK Then If Msgbox2("Exit?","Exit to App","Yes","","No",Null)<> DialogResponse.POSITIVE Then Return True End If Return False End Sub Amarildo Lázaro said: and Home Button. Click to expand... It is not possible. When you click the Home button the App is not killed (as in the case of the Back button) but is put in the background. You could put a check and delay the exit or put the App back in the foreground (Maybe you could start a service that reopens the App in the foreground, but I've never tried is just a hypothesis) Code: Copy Sub Activity_Pause (UserClosed As Boolean) If UserClosed Then Sleep(3000) 'It will give the time to the unfinished services to complete the operations '(Astrem, for example, transmissions on bluetooth printers and ecc.) End If End Sub Last edited: Oct 11, 2018 Upvote 0
Amarildo Lázaro said: how to intercept the CameBack Click to expand... Code: Copy Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event If KeyCode = KeyCodes.KEYCODE_BACK Then If Msgbox2("Exit?","Exit to App","Yes","","No",Null)<> DialogResponse.POSITIVE Then Return True End If Return False End Sub Amarildo Lázaro said: and Home Button. Click to expand... It is not possible. When you click the Home button the App is not killed (as in the case of the Back button) but is put in the background. You could put a check and delay the exit or put the App back in the foreground (Maybe you could start a service that reopens the App in the foreground, but I've never tried is just a hypothesis) Code: Copy Sub Activity_Pause (UserClosed As Boolean) If UserClosed Then Sleep(3000) 'It will give the time to the unfinished services to complete the operations '(Astrem, for example, transmissions on bluetooth printers and ecc.) End If End Sub
Erel B4X founder Staff member Licensed User Longtime User Oct 11, 2018 #4 Kiosk applications can remove the home key: https://www.b4x.com/android/forum/threads/device-owner-tasklock-kiosk-apps-2017.81765/ Upvote 0
Kiosk applications can remove the home key: https://www.b4x.com/android/forum/threads/device-owner-tasklock-kiosk-apps-2017.81765/