Android Question How to get current page?

gacar

Active Member
i want an if condition like as

B4X:
if currentpage("page1") then  
dont connect to database
else if currentpage("page2") then
connect to database
end if
 

teddybear

Well-Known Member
Licensed User
i want an if condition like as

B4X:
if currentpage("page1") then 
dont connect to database
else if currentpage("page2") then
connect to database
end if
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

Active Member
B4X:
Dim CurrentPageId As String = B4XPages.GetPageId(Me)
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

gacar

Active Member
sohbet.jpg
 
Upvote 0

teddybear

Well-Known Member
Licensed User
To the picture,I could not understand your intent

but to the code.
i want an if condition like as

B4X:
if currentpage("page1") then
dont connect to database
else if currentpage("page2") then
connect to database
end if
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
Top