Activity_Pause

cymorg

Member
Licensed User
Longtime User
The Activity_Pause(UserClosed as Boolean) is not running in my app. I have tried closing the app using various methods (Home button, back button, launching other activities etc.) At no time, in any scenario, does the Activity_Pause run. Below are 2 examples of code within the pause subroutine (from different activities). Neither runs, ever. Any ideas why?

B4X:
Sub Activity_Pause(UserClosed As Boolean)
   ToastMessageShow("Activity_Pause raised this message", True)
End Sub

B4X:
Sub Activity_Pause(UserClosed As Boolean)
   If UserClosed = True Then
      Dim result As Int
      result = Msgbox2("Do you want to switch APN?", "APN Settings","Yes", "", "No", Null)
      If result = DialogResponse.POSITIVE Then
         Dim i As Intent
         i.Initialize("android.settings.APN_SETTINGS", "")
         StartActivity(i)
      End If
   End If
End Sub

Thanks
 

cymorg

Member
Licensed User
Longtime User
Thanks TheDesolateSoul. The ToastMessage does work. Apart from the Msgbox not working during Activity_Pause there seem to be plenty of other methods that will not work at this late stage of code execution. Now that I am aware that some methods are expected to work, and others not I can workaround the problem. Documentation that explains why some methods will execute, and some will not, would be nice to have.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
I'm not much of a documentation guy. I must have read it somewhere but I dont remember it now!
The only thing that will not work in Activity_Pause is any modal dialog that requires program execution to stop/pause.
This includes messageboxes and custom dialogs. Also, breakpoints will not work. I cant think of anything else that will not run in Activity_Pause.
You can read this:
Tricks Of The Trade - Basic4android Wiki
 
Upvote 0
Top