Android Question .

ssg

Well-Known Member
Licensed User
Longtime User
hi there,

after timer1.initialize, call timer1.enabled = true.

then add a sub timer1_tick and in that sub place panel1.visible = false.

hope that is of help!

good luck!
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
Working on the guidelines above i wanted my splash screen to appear for 3 seconds then show the main application screen.
So I created 2 layouts: "splashpanel.bal" for the splash screen and "somelayout.bal" for the application (for testing, just a single button that displays a msgbox)

==================================
tmr as timer declared in Process_Globals


------------------------------------
Sub Activity_Create(FirstTime As Boolean)
If firsttime Then Splash_Show

activity.LoadLayout("somelayout")
End Sub

Sub splash_show
activity.LoadLayout("splashpanel")
tmr.Initialize("tmr",3000)
tmr.Enabled=True
....adjusting the panel size & position
End Sub

Sub tmr_Tick
splpan.Enabled = False
splpan.Visible = False
tmr.Enabled = False
End Sub

=============================

This showed the splash for 3 second BUT ALSO the button (from "somelayout"). After 3 secs only the button remain on screen. So I tried to "delay" loading the main layout by this:

=========================
Sub Activity_Create(FirstTime As Boolean)
If firsttime Then Splash_Show
Do While tmr.Enabled
DoEvents
Loop
activity.LoadLayout("somelayout")
End Sub

=========================

BUT the splashscreen NEVER vanished (the tmr_tick never 'fired') and the button never appeared!!!! Help anyone?
 
Upvote 0

ZJP

Active Member
Licensed User
Longtime User
Hi,

Please, can you use the tags "
B4X:
 and
" for examples . This is more readable. Thank you.

JP
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
ok. here we go again....

Working on the guidelines above i wanted my splash screen to appear for 3 seconds then show the main application screen.
So I created 2 layouts: "splashpanel.bal" for the splash screen and "somelayout.bal" for the application (for testing, just a single button that displays a msgbox)

==================================
tmr as timer declared in Process_Globals


------------------------------------
B4X:
Sub Activity_Create(FirstTime As Boolean)
If firsttime Then Splash_Show

activity.LoadLayout("somelayout")
End Sub

Sub splash_show
activity.LoadLayout("splashpanel")
tmr.Initialize("tmr",3000)
tmr.Enabled=True
....adjusting the panel size & position
End Sub

Sub tmr_Tick
splpan.Enabled = False
splpan.Visible = False
tmr.Enabled = False
End Sub
=============================

This showed the splash for 3 second BUT ALSO the button (from "somelayout"). After 3 secs only the button remain on screen. So I tried to "delay" loading the main layout by this:

=========================
B4X:
Sub Activity_Create(FirstTime As Boolean)
If firsttime Then Splash_Show
Do While tmr.Enabled
DoEvents
Loop
activity.LoadLayout("somelayout")
End Sub
=========================

BUT the splashscreen NEVER vanished (the tmr_tick never 'fired') and the button never appeared!!!! Help anyone?
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
Erel, you are right. But i intend to "isolate" the splash screen as much as possible from the main activity (so i can use it in other apps) and loading the main app's layout in the timer tick of the splash screen defies this purpose.
 
Upvote 0

lagore

Active Member
Licensed User
Longtime User
Erel is correct, the way you have defined your 'If' statement causes the splash to be loaded and then immediately the "activity.LoadLayout("somelayout")" as it is the next statement in sequence putting one on top of the other. If you used an If Else this would get over this, but you would still have to put the "activity.LoadLayout("somelayout")" in the Timer_tick routine as well.
B4X:
Sub Activity_Create(FirstTime As Boolean)
If firsttime Then 
      Splash_Show
Else
      activity.LoadLayout("somelayout")
End Sub
This way the you have both options covered;
1) On first load you will get your splash screen then 3 sec later timer1 will fire this routine will close the splash screen, disable the timer1 and load the main layout.
2)If it is not 'firsttime' then we do not want the splash screen and the 'Else' will cause the main layout to be loaded.
Edward
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Easy Clean Way to Pause Code

Hello All,

Here is a very easy and clean way to pause the code for the splash screen and you do not have to use any timers! Copy this code in as a sub, where you want a pause just enter:

Example: Pause(3)

Just put the number of seconds you want to pause in the () as an INT. ;)

Thanks,

Margret

B4X:
Sub Pause(Tvar As Int)
   Dim Tstart As Long
   Tstart = DateTime.Now
   Do While DateTime.Now-Tstart < (Tvar*1000)
   Loop
End Sub
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
It's not the emulator's problem, it's MY problem!!!
the main activity shd be changed to:

B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime OR Not(Done) Then  <==== the change
  Splash_Show
Else
  activity.LoadLayout("somelayout")
End If
End Sub
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
Margret,

I don't know the internals of B4A/Java/Android (Erel should be THE source for the answer) but as a seasoned programmer i think that would just tie up the processor, perhaps preventing it from other tasks.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Hi boten,
I would do it that way:
With two panels added by code, but each panel has its own layout file.
B4X:
[SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff]Sub [/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Process_Globals[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  Dim[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Timer1 [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b]Timer[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
 
[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Globals[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  Dim[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] pnlMain, pnlSplash [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b]Panel[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
 
[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Activity_Create(FirstTime [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b]Boolean[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]  pnlMain.Initialize([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]  Activity.AddView(pnlMain, [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]100%x[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]100%y[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]  pnlMain.Visible = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] FirstTime [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]    pnlSplash.Initialize([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]    Activity.AddView(pnlSplash, [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]100%x[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]100%y[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]    Timer1.Initialize([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Timer1"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]3000[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]    pnlSplash.LoadLayout([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Splash"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]    Timer1.Enabled = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]    pnlMain.LoadLayout([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Main"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  Else[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]    pnlMain.LoadLayout([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Main"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]    pnlMain.Visible = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  End [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
[SIZE=2][FONT=Courier New][COLOR=#0000ff]End Sub[/COLOR][/FONT][/SIZE]
 
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Timer1_Tick[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]  pnlSplash.Visible = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  pnlMain.Visible = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  Timer1.Enabled = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][/FONT]
[SIZE=2][FONT=Courier New][COLOR=#0000ff]End Sub[/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
Attached the small test program.

Best regards.
 

Attachments

  • SplashScreen.zip
    92.7 KB · Views: 433
Upvote 0

boten

Active Member
Licensed User
Longtime User
Hi Klaus,

tried your pgm. When main activity is finally shown, and the user wants to quit and press the back btn, the app is still in memory (until kicked out by the system) so if you start the program again, the splash doesn't show.

I want to show the splash whenever the user starts it (after he previously exited) but not show the splash if the user just switched to another app (e.g pressed home) but did NOT intend to quit. (just like selecting another open app from the task bar in windows), for this purpose i had to use the 'Done' semaphore.

I just realized my long post from this morning July,25 was somehow drifted into a limbo. I'll post what i've done, and is working soon.
 
Last edited:
Upvote 0

boten

Active Member
Licensed User
Longtime User
here is what's working:

B4X:
Sub Process_Globals
Dim Done As Boolean   ' semaphore to signal if splash shown already
Done=False
End Sub

the structure of the pgm is:
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime OR Not(Done) Then
  Splash_Show
Else
  activity.LoadLayout("somelayout")
End If
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
tmr.Enabled=False  ' if splash itself is interrupted (e.g. orientaion) then stop it
Done=True
If UserClosed Then 
  Done=False
End If  
End Sub

Sub button1_click
 Msgbox("clicked","the real app")
End Sub

Sub Splash_Show
 If Done Then Return  ' might be redundant, just to be sure & safe
   activity.LoadLayout("splashpanel")
   ... adjust the panel
   tmr.Initialize("tmr",3000)
   tmr.Enabled=True
End Sub

Sub tmr_Tick
  splpan.Enabled=False
  splpan.Visible=False
  tmr.Enabled=False
  Done=True
  activity.LoadLayout("somelayout")
End Sub

The 'Done' semaphore will be true if timer tick fired, or if the app is paused. In the case of the app being
paused we want to "abandon" any hope of redisplaying the splash (as in the case of change orientation in the
middle of the splash).
When the user press back, that is wants to quit the app, Done is changed back to false in order to show it again on the
next program start, but if the pasue was due to other cause (orientation, home scrren, phone rings...) then we don't show the splash.

the statement: If FirstTime OR Not(Done) Then
takes care of this situation.

Hope this is clear enough
 
Upvote 0

cirollo

Active Member
Licensed User
Longtime User
I cannot remove the splash screen!

HI! Following this examples, my splash screen works but when the mainpanel opens, the splash screen remains as background!

how can I remove it???

cirollo
 
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi cirollo,

I hope this will solve your problem:

On the main module:

B4X:
Sub Globals
   Dim Timer1       As Timer
   Dim edtInfo    As EditText    'in case you want an info/announcement as a "splash"display
   Dim Panel1, Panel2 As Panel      'the panel1 to display the info/announcement, panel2 for the main panel
End Sub

B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("main.bal")
   Panel1.Visible=True
   Timer1.Initialize("Timer1", 1000)   '1000= for 1 second "splash" panel is visible
   Timer1.Enabled=True
   Panel2.Visible=False
End Sub

B4X:
Sub Timer1_tick
   Panel1.Visible =False                'after 1 second, "splash"display panel will be gone
   Timer1.Enabled = False
   Panel2.Enabled = True
   Panel2.Visible = True
End Sub

Well, that's about it.
 
Last edited:
Upvote 0
Top