API 4 will raise the Activity Pause when Exit is selected. API 5 will not.
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Select Msgbox2("Do you want to Exit?", "", "Exit", "Cancel", "", Null)
Case DialogResponse.CANCEL: Return True
End Select
End If
Return False
End Sub
My workaround is to replace "Return False" with Activity.Finish. Anyone using an exit function like mine with SDK 5 or higher and have no problems?
B4X:
If KeyCode = KeyCodes.KEYCODE_BACK Then
Select Msgbox2("Do you want to Exit?", "", "Exit", "Cancel", "", Null)
Case DialogResponse.CANCEL: Return True
Case Else: Activity.Finish
End Select
End If
I've tried the following code on Android 3.1 and it works properly. Activity_Pause is raised. Note that the debugger doesn't stop in this sub so it may be confusing:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Select Msgbox2("Do you want to Exit?", "", "Exit", "Cancel", "", Null)
Case DialogResponse.CANCEL: Return True
End Select
End If
Return False
End Sub
Sub Activity_Pause(UserClosed As Boolean)
Log("paused")
End Sub
I've tried the following code on Android 3.1 and it works properly. Activity_Pause is raised. Note that the debugger doesn't stop in this sub so it may be confusing:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Select Msgbox2("Do you want to Exit?", "", "Exit", "Cancel", "", Null)
Case DialogResponse.CANCEL: Return True
End Select
End If
Return False
End Sub
Sub Activity_Pause(UserClosed As Boolean)
Log("paused")
End Sub
I have a log into the Activity_Pause and will not show on the debugger screen. I assure you the Activity_Pause will not get raised. It may have to do with my Chinese phone, perhaps?
2.2.1 Android Version
Proof on the Video attached. avi
Rename .zip to .rar. Better then zip. Zip exceeds 400k.