Private Sub On_KeyPress(ViewTag As Object, KeyCode As Int, KeyEvent As Object) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Dim j As JavaObject = KeyEvent
Dim eventCode As Int = j.RunMethod("getAction",Null)
Log("EventCode is:"&eventCode)
If (eventCode = 0) Then
' 0=ACTION_DOWN, 1=ACTION_UP, 2=ACTION_MULTIPLE
Main.MonitoringBackButtonPressed = True ' This is just to let the MonitoringListTypes page know that the user pressed then back button on its child page, our code does different things depending if you are coming down to the page or working you way back up towards to home page.
B4XPages.ShowPageAndRemovePreviousPages("MonitoringListTypes")
End If
Return True
Else
Return False
End If
End Sub