iOS Question Back Button and activity resume

Marco Maria Vilucchi

Active Member
Licensed User
Longtime User
Hi,
when i press "back" the App return to main page.
On Android i can use Activity_Resume.
How can i intercept "back" button pression on B4I?
Can someone help me?
Ths
Marco

upload_2015-7-14_8-53-9.png
 

Attachments

  • upload_2015-7-14_8-47-29.png
    upload_2015-7-14_8-47-29.png
    100.2 KB · Views: 196

imbault

Well-Known Member
Licensed User
Longtime User
There must be several methods, the one I have used is working with variables, let's say LastPage for saving lastpage and Pb used in all pages
So in main
B4X:
Sub Process_Globals
    Private LastPage="" As String
    Public Pb ="" as String
    Private HomeScreen As Page
....
Private Sub Application_Start (Nav As NavigationController)
   HomeScreen.Initialize("HomePage")

Let's say your main page calls a Parameter page, before calling parameters.show, just do:
B4X:
    LastPage = "parameters"
parameters.show

In Parameter, you can intercept the page is going to "back" in this Sub Page_Disappear , and saving what you want before page really disappears:
B4X:
Private Sub parameters_Disappear
   If PwrM <= PwrL Then
        Main.Pb = Main.Pb  & "Warning PowerM Should be Greater than PowerL" & CRLF
    End If

...

In Main, a Sub will be raises, Page_Appear, here you can check the LastPage and pb

B4X:
Private Sub HomePage_Appear
    If LastPage <> "" Then
        ' handle saves
        If LastPage = "parameters" Then
            If Pb <> "" Then
       
                Msgbox(Pb,"Please fix errors in Parameters")
                Pb = ""
                parameters.Show
             End If
        End If


        LastPage = ""
    End If

End Sub

Hope this will show you how to do
 
Last edited:
Upvote 0
Top