Android Question Splash Screen 2022 (only Android)

peacemaker

Expert
Licensed User
Longtime User
Hi, All

Any simple solution for a splash screen (without B4Xpages, yes, without them) for Android only in 2022 ?
 

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
What you mean exactly?
I know you know how to make activity as splash screen with timer to close it and show next app entry,
Or did you mean activity as splash appear before B4XPage appears?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
to make activity as splash screen with timer to close
Actually indeed this is an issue: yes, Main activity may be used as a splash screen, and after time is out - Main starts Second activity and makes Self.Finish.
But next it's impossible to make the full exit in the Second activity - the Main is re-started again at any try to make Finish or ExitApplication, as it was the previous one.
 
Upvote 0

Sagenut

Well-Known Member
Licensed User
Longtime User
Something like this?
 

Attachments

  • Splash_Activity.zip
    10.2 KB · Views: 62
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Strange.
1) When I created this attached small example - all works fully OK !
2) But when i make this way my real (big) project with the same 2 activities, but AppCompatActivity compatible with a ACToolBarLight - it works wrong, the Main is re-started at exit.
 

Attachments

  • Splash_example.zip
    21.7 KB · Views: 60
Upvote 0

Sagenut

Well-Known Member
Licensed User
Longtime User
Activity Lifecycle it's the worst thing Android has (now we have B4XPages that help a lot).
I would not get crazy using an Activity just to show a SplashScreen, considering that you can simply do it with a Panel in a single activity.
Or maybe I am missing something?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
other modules in your big project recreating main activity
For sure - not. It's the same way - Main module is used as the starting splash. Only.


you can simple do it with a Panel
Also not - there are lots of modules and objects must be initialized during Activity start, and also _Resume event is going ASAP after Activity_Create, and makes errors if something is not initialized on time at _Create...
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
And this is the big reason we shifted toward B4XPages methodology in new projects, but our old big projects without B4XPages are having this problem and not solved yet, we can't convert them to B4XPages type, many of them working on it for a years!
We need an excellent approach for your question solution.
I don't understand why exitapplication function does not work as its name!
 
Upvote 0

Sagenut

Well-Known Member
Licensed User
Longtime User
Include a Panel as Splash Screen with high Elevation in your layout and set it Not Visible in Designer.
Then in your code
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    If FirstTime Then
        ShowSplash
    End If
    'Here everything goes on.......
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

private Sub ShowSplash
    SplashPanel.Visible = True
    Sleep(4000)
    SplashPanel.Visible = False
End Sub
 
Upvote 0

Sagenut

Well-Known Member
Licensed User
Longtime User
Modified example.
 

Attachments

  • Splash_Activity.zip
    9.6 KB · Views: 99
Upvote 0
Solution
Top