Sub Process_Globals
' exit timer, used to time between user pressing back button twice
Dim exitTimer As Timer
Dim exitTimer_tick_duration As Int = 2000 ' tick every 2 seconds
End Sub
Sub exitTimer_Tick
exitTimer.Enabled=False
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK Then
If (exitTimer.Enabled=False) Then
ToastMessageShow("Press Again To Exit",False)
If (exitTimer.IsInitialized=False) Then
exitTimer.Initialize("exitTimer",exitTimer_tick_duration)
End If
exitTimer.Enabled=True
Return True
Else
' exit app, timer is running and it hasn't 'ticked' round yet by tick interval (2 secs or whatever). so exit now
gps_ref.Stop
exitTimer.Enabled=False
closeApplication=True
Activity.Finish
ExitApplication
Return True
End If
End If
End Sub