Sub Activity_KeyPress (KeyCode As Int) As Boolean
Dim bResult As Boolean = False
CallSubDelayed3(Me, "ProcessKeyPress", KeyCode, bResult)
Return bResult
End Sub
Sub ProcessKeyPress(keycode As Int, Result As Boolean)
' handle the back key
If keycode = KeyCodes.KEYCODE_BACK Then
' get confirmation that the user wished to exit
Dim Res As Int
Dim BD As BetterDialogs
Res = BD.Msgbox("Please confirm","Are you sure you wish to exit the application.","Yes","","No",Null)
If Res = -2 Then
' keep app open
Result = True
Return
Else
' close the app
Main.iResume = 1
Activity.Finish
End If
End If
Result = False
End Sub