Sub Activity_KeyPress (KeyCode As Int) As Boolean
Select KeyCode
Case KeyCodes.KEYCODE_BACK
Dim m As Int
m = Msgbox2("Are you sure to close this app?", "Confirmation", "Yes", "", "No", Null)
If m = DialogResponse.POSITIVE Then
ExitApplication
Else
Return True
End If
End Select
End Sub
I saw most of the apps use a toastermessage saying "Press back key again to exit"
Here I can easily show that message after single back button click. But how can I detect second button press to exit the app?
Use an indicator say a Boolean that is set to false when the activity is started then in 'Activity_KeyPress' test the boolean if false display your toast message and set the boolean to true, next time around with the test being true allow the back key do its job. If you wanted to be really annoying and have it happen a few times you could use a counter with a 'case' statement and different toast messages.