Android Question How to show two splashscreen before the main form?

asales

Expert
Licensed User
Longtime User
I want to show 2 splashscreen in my app before show the main screen.
The first splashscreen (2 seconds) shows the logo of app, load from a layout.
The second splashscreen (other 2 seconds) shows other info (or my own advertising), load from other layout.

How I can do this?

Thanks in advance.
 

stevel05

Expert
Licensed User
Longtime User
Use a timer initialized to 2 seconds (2000ms), then close the first and open the second at the first tick call, then close the second and disable the timer on the second tick call.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Use a timer initialized to 2 seconds (2000ms), then close the first and open the second at the first tick call, then close the second and disable the timer on the second tick call.
Thanks. Works fine. See my code:

B4X:
Sub Process_Globals
    Dim Timer1 As Timer
    Dim Timer2 As Timer
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("splash1")
    Timer1.Initialize("Timer1", 2000)
    Timer1.Enabled=True
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub Timer1_tick
    Timer1.Enabled = False
    Activity.LoadLayout("splash2")
    Timer2.Initialize("Timer2", 2000)
    Timer2.Enabled=True
End Sub

Sub Timer2_tick
    Timer2.Enabled = False
    Activity.LoadLayout("Main")
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You can actually do it with one timer:

B4X:
Sub Process_Globals
    Dim Timer1 As Timer
End Sub

Sub Globals
    Dim Count As int
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("splash1")
    Timer1.Initialize("Timer1", 2000)
    Timer1.Enabled=True
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    Timer1.Enabled = False
End Sub

Sub Timer1_tick
  Count = Count + 1
  If Count = 1 Then
        Activity.LoadLayout("splash2")
        Return
   End If
    If Count = 2 Then
        Timer1.Enabled = False
        Activity.LoadLayout("Main")
    End If
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…