B4X:
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
ShoulIClose = True ' This tells others to close
Activity.Finish
End If
Return True
Case Else
Return False
End Select
End Sub
I used the above code but my activity reloads and i have to click back again to close the activity, why this is happening?