G gacar Active Member Mar 2, 2022 #1 i want an if condition like as Code: if currentpage("page1") then dont connect to database else if currentpage("page2") then connect to database end if
i want an if condition like as Code: if currentpage("page1") then dont connect to database else if currentpage("page2") then connect to database end if
Solution LucaMs Mar 2, 2022 Code: Private Sub B4XPage_Appear 'Connect End Sub Private Sub B4XPage_Disappear 'Disconnect End Sub
Erel B4X founder Staff member Licensed User Longtime User Mar 2, 2022 #2 Code: Dim CurrentPageId As String = B4XPages.GetPageId(Me) Upvote 0
teddybear Well-Known Member Licensed User Mar 2, 2022 #3 gacar said: i want an if condition like as Code: if currentpage("page1") then dont connect to database else if currentpage("page2") then connect to database end if Click to expand... I think you should set a boolean state for page1 in service. when the page1 Activity_Pause it is false, else true. Upvote 0
gacar said: i want an if condition like as Code: if currentpage("page1") then dont connect to database else if currentpage("page2") then connect to database end if Click to expand... I think you should set a boolean state for page1 in service. when the page1 Activity_Pause it is false, else true.
G gacar Active Member Mar 2, 2022 #4 Erel said: Code: Dim CurrentPageId As String = B4XPages.GetPageId(Me) Click to expand... This is not right for me. teddybear said: I think you should set a boolean state for page1 in service. when the page1 Activity_Pause it is false, else true. Click to expand... Yes, in a similar way. How can I do that? Upvote 0
Erel said: Code: Dim CurrentPageId As String = B4XPages.GetPageId(Me) Click to expand... This is not right for me. teddybear said: I think you should set a boolean state for page1 in service. when the page1 Activity_Pause it is false, else true. Click to expand... Yes, in a similar way. How can I do that?
G gacar Active Member Mar 2, 2022 #5 Erel said: Code: Dim CurrentPageId As String = B4XPages.GetPageId(Me) Click to expand... I have a chat window. If a user leave chat i want mark it leaved. But chat windows codes working behind still, i cant stop it. So if a user leave from chat page not working code. Upvote 0
Erel said: Code: Dim CurrentPageId As String = B4XPages.GetPageId(Me) Click to expand... I have a chat window. If a user leave chat i want mark it leaved. But chat windows codes working behind still, i cant stop it. So if a user leave from chat page not working code.
LucaMs Expert Licensed User Longtime User Mar 2, 2022 #7 Code: Private Sub B4XPage_Appear 'Connect End Sub Private Sub B4XPage_Disappear 'Disconnect End Sub Upvote 0 Solution
teddybear Well-Known Member Licensed User Mar 2, 2022 #8 gacar said: View attachment 126271 Click to expand... To the picture,I could not understand your intent but to the code. gacar said: i want an if condition like as Code: if currentpage("page1") then dont connect to database else if currentpage("page2") then connect to database end if Click to expand... You can define a global variable IscurrentPage2 for page2 in code or service module. you can set the value is true when page2 is create or resume event, false is in pause event. You can use the code to judge if page2 is current page B4X: if yourmodule.IscurrentPage2 then connect database else disconnect endif Upvote 0
gacar said: View attachment 126271 Click to expand... To the picture,I could not understand your intent but to the code. gacar said: i want an if condition like as Code: if currentpage("page1") then dont connect to database else if currentpage("page2") then connect to database end if Click to expand... You can define a global variable IscurrentPage2 for page2 in code or service module. you can set the value is true when page2 is create or resume event, false is in pause event. You can use the code to judge if page2 is current page B4X: if yourmodule.IscurrentPage2 then connect database else disconnect endif
G gacar Active Member Mar 2, 2022 #9 LucaMs said: Code: Private Sub B4XPage_Appear 'Connect End Sub Private Sub B4XPage_Disappear 'Disconnect End Sub Click to expand... Thank you very much. It is worked Upvote 0
LucaMs said: Code: Private Sub B4XPage_Appear 'Connect End Sub Private Sub B4XPage_Disappear 'Disconnect End Sub Click to expand... Thank you very much. It is worked
jahswant Well-Known Member Licensed User Longtime User Mar 2, 2022 #10 Also use this to get TopPage B4X: Dim TopPage As String = B4XPages.GetManager.GetTopPage.Id Upvote 0
LucaMs Expert Licensed User Longtime User Mar 2, 2022 #11 jahswant said: Also use this to get TopPage B4X: Dim TopPage As String = B4XPages.GetManager.GetTopPage.Id Click to expand... ... to get TopPageID Upvote 0
jahswant said: Also use this to get TopPage B4X: Dim TopPage As String = B4XPages.GetManager.GetTopPage.Id Click to expand... ... to get TopPageID