Android Question [Solved] B4XPages get FirstTime=False when device rotates

angel_

Well-Known Member
Licensed User
Longtime User
I have the same problem, every time the screen is rotated (I only have 1 Page) the created event is fired, How I can get FirsTime = True when the app starts and False when it rotates?

 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
I only have one activity

I thought of two options:
Starter:
Sub Process_Globals  
    Public FirstTime As Boolean
End Sub

Sub Service_Create
    FirstTime = True
End Sub

or
Main:
Sub Process_Globals
    Public FirstTimeMain As Boolean
End Sub

Sub Activity_Create(FirstTime As Boolean)
    FirstTimeMain = FirstTime
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
End Sub

Then:
B4XMainPage:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    '...code
   
    If Starter.FirstTime Then    'or If Main.FirstTimeMain Then
        'code FirstTime
    Else
        'code No FirstTime
    End If  
End Sub

Which is the best option?
 
Upvote 0
Top