Hello
Is it possible to apply a condition if an activity is loaded?
I have a button which must have a different action depending on whether this or that activity is loaded.
Example, like:
Sub Button1_Click
If activity(activity name) is loaded Then
Mylabel.text = "Hello"
end if
End Sub
What can be the syntax if it is possible?
Thank you
Sub Process_Globals
Dim WhichActivityIsLoaded As String
End Sub
Sub Btn_Click
Try
If WhichActivityIsLoaded="Page1" Then
lbl.text="Hello"
End If
Catch
Log(LastException)
End Try
End Sub
and in the page 1 :
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Page2.WhichActivityIsLoaded = "Page 1"
End If
end sub
For me i always make code module called : GlobalParameters that contains the Parameters that i want to be globally used in the app, it's really helpful
Please use [code]code here...[/code] tags when posting code.
The sooner you switch to B4XPages, the sooner things will become simpler.
You can check if an activity is in the foreground with IsPaused(Activity).
If you want to know whether the activity was created at least once then use a process global variable as answered above.