Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Select layout
Case "NewGame" ,"Options", "LoadGame"
allinvisible
MainMenu
Return True
Case "HowtoPlay"
allinvisible
Options
Return True
Case "GamePlay"
Dim result As Int
result = Msgbox2("Exit Game?", "Exit", "Exit", "Main Menu", "Continue playing",Null)
If result = DialogResponse.POSITIVE Then
Msgbox(gmid,"gameid")
ExitApplication
Else IF result = DialogResponse.CANCEL Then
allinvisible
MainMenu
Return True
Else If result = DialogResponse.NEGATIVE Then
'continue playing
Return True
End If
Case "MainMenu"
ExitApplication
End Select
End If
End Sub