Sub Activity_KeyPress(KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Selection = Msgbox2("Exit the app?", "Confirmation", "Yes", "", "No", Null)
Select Selection
Case DialogResponse.POSITIVE
Activity.Finish
Case DialogResponse.CANCEL
Return True
Case DialogResponse.NEGATIVE
Return True
End Select
End If
End Sub
Sub Activity_KeyPress(KeyCode As Int) As Boolean
Dim Selection As Short
If KeyCode = KeyCodes.KEYCODE_BACK Then
Selection = Msgbox2("Exit application?".ToUpperCase, "C o n f i r m a t i o n", "Yes", "", "No", Null)
Select Selection
Case DialogResponse.POSITIVE
Activity.Finish
Case DialogResponse.CANCEL, DialogResponse.NEGATIVE
Return True
End Select
End If
End Sub
Sub Activity_KeyPress(KeyCode As Int) As Boolean
If Msgbox2("Exit app?", "Exit", "Yes", "", "No", Null) = DialogResponse.POSITIVE Then Activity.Finish Else Return True
End Sub
Sub Activity_KeyPress(KeyCode As Int) As Boolean
If Msgbox2("Exit app?", "Exit", "Yes", "", "No", Null) = -1 Then Activity.Finish Else Return True
End Sub
Sub Activity_KeyPress(KeyCode As Int) As Boolean
Dim Selection As Short
If KeyCode = KeyCodes.KEYCODE_BACK Then
Selection = Msgbox2("Exit application?".ToUpperCase, "C o n f i r m a t i o n", "Yes", "", "No", Null)
Select Selection
Case DialogResponse.POSITIVE
Return False
' Activity.Finish
Case DialogResponse.CANCEL, DialogResponse.NEGATIVE
Return True
End Select
End If
End Sub
I've been trying this on my app, it displays the msgbox but then quits straight out and you don't have time to give a response.
Sub Process_Globals
Dim exitdelay As Timer
exitdelay.Initialize("exitdelay",10)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
'added to END of Sub - seems to be needed.
If UserClosed Then
Activity.Finish
End If
End Sub
Sub Activity_KeyPress(KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
exitdelay.Enabled = True
Return True
End If
End Sub
Sub exitdelay_tick
exitdelay.Enabled = False
If Msgbox2("Exit app?", "Exit", "Yes", "", "No", Null) = -1 Then
Activity_Pause (True)
End If
End Sub
After a lot of :BangHead:, I managed to solve my problem...
(Additions/adaptations)
B4X:Sub Process_Globals Dim exitdelay As Timer exitdelay.Initialize("exitdelay",10) End Sub Sub Activity_Pause (UserClosed As Boolean) 'added to END of Sub - seems to be needed. If UserClosed Then Activity.Finish End If End Sub Sub Activity_KeyPress(KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then exitdelay.Enabled = True Return True End If End Sub Sub exitdelay_tick exitdelay.Enabled = False If Msgbox2("Exit app?", "Exit", "Yes", "", "No", Null) = -1 Then Activity_Pause (True) End If End Sub
Hope this helps someone else.
It wasn't a question, but feedback from an old post from someone that gave me resolution while researching all (old and new) posts?Wrong thread.
You always should create a new thread for any new question.
Especially If the thread is four years old
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?