SDK 5 Pause not raised with Keycode

Scantech

Well-Known Member
Licensed User
Longtime User
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
 
Last edited:

Scantech

Well-Known Member
Licensed User
Longtime User
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
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
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
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User

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.
 

Attachments

  • SDK5Test.zip
    37.3 KB · Views: 163
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…