Android Question Help with preventing application from exiting

bobdoy

New Member
Hello, I currently have this code written:

Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Dim result As Int = Msgbox2("Would you like to close this application?","Exit?","Yes","Cancel","",Null)
If result = DialogResponse.CANCEL Then Return True
End If
End Sub

What it should do is if the user presses "Yes", it must close. Thats why I did not add any code for that, to allow the program to exit like it should. If the user presses "Cancel" the program should remain open.

The problem is that pressing either buttons causes the program to force close, does anybody have a suggestion of what I may be doing wrong?

Thanks
 
Top