Вариант с подтверждающим месседжбоксом
Вариант с двойным нажатием в течении 3х секунд
Code:Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If Msgbox2("Are you sure to exit?", "", "Yes", "", "No", Null) = DialogResponse.POSITIVE Then Return False ExitApplication '...or whatever other previous killing actions. Else Return True End If Else Return False ' Handle the other presses in the OS End If End Sub
Code:Sub Globals Dim closeCounter As Int ' For double click exit routineDim closeTimer As Long end sub Sub Activity_KeyPress (KeyCode As Int) As Boolean Select KeyCode Case KeyCodes.KEYCODE_BACK closeCounter = closeCounter + 1 ' Handle the user exit request ' First time so start the counter If closeCounter = 1 Then closeTimer = DateTime.Now ToastMessageShow("Press Back again to exit", False) End If ' Second time but not within 3 seconds, reset to "First time" If closeCounter = 2 AND DateTime.Now > closeTimer + 3000 Then closeCounter = 1 closeTimer = DateTime.Now ToastMessageShow("Press Back again to exit", False) End If ' Two tries within 3 seconds, we're done If closeCounter = 2 Then closeCounter = 0 Activity.Finish End If Return True Case Else Return False End Select End Sub
Комментариев нет:
Отправить комментарий