Android Question How to hide initial/default activity until layout loads

JohnC

Expert
Licensed User
Longtime User
When my app first starts, an activity with the Titlebar showing my app's name and a black body is very briefly displayed, then the layout I am loading in the Activity_Create is displayed.

How can I prevent this unknown initial/default activity from displaying before my actual desired layout is loaded?

I even have the below in the "Main" activity:
B4X:
#Region  Activity Attributes
    #FullScreen: false
    #IncludeTitle: False
#End Region
 

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
Have you tried to add something like this in manifest editor?
B4X:
 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
My first attempt I added it to the manifest wrong, but now I got it working!

Thanks.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I wonder why this is not added as a default in the manifest, because who would want a default activity to briefly show up when thier app first starts?
 
Last edited:
Upvote 0

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
I think the problem is that would be without themes (holo, material, light, etc.)

And would need combinations.

Something like that:
B4X:
<stylename="MyTheme"parent="android:Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item></style>
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Erel,

Why is there some unknown activity (with a default layout) quickly being displayed right before the first ".Loadlayout" of the "Main" activity is able to load the desired layout?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Hi Erel,

But if I completely hide the Titlebar, then where will the three dots (the "Menu" for my app) appear for devices with android 4+ (that don't have a dedicated/hardware "menu" button at the bottom)?
 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
But then how will end users without a hardware "menu" button display my app's menu?

Also, it seems that if I hide the titlebar, my app can't include/use an Actionbar, is this correct?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Hi Erel,

It does appear quickly, less then a second (without any tasks in the Activity_Create), but even that 1 second gives the app a less-polished/unprofessional appearance.

Idea: You created the "Starter" service to insure certain code is executed before anything else. Would it be possible to add the ability to specify a "main" layout in the starter sub that would be applied to the Main activity BEFORE it gets displayed? This way it wont briefly display the "default" layout for the Main activity, then have to change to the desired layout.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
And if this happens when loading subsequent activities while an app if running (but I haven't noticed this yet), maybe you could create a new parameter for StartActivity call:

StartActivity("setup","config")

Where the second param is the layout you want the new activity to use before it is displayed.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Thanks, I'll give that a shot... but just to make sure I understand all this correctly...

1) Because my app doesn't have a titlebar/actionbar, then 4.0+ devices that don't have a dedicated menu button will have nowhere to put the menu/overflow 3-dot menu icon, so it wont appear anywhere in my app - is this right?

2) Accordingly, then it's my responsibility to put the 3-dot icon in the top right corner of my app (in the AppCompat toolbar) and display the app's menu programmically using "Activity.OpenMenu" when the user clicks it. Is this right?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Also, do you know if/how Android Studio developers get around this issue?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
easy enough, create a splash screen with black background!
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
That just substitutes one not great visual with another - it's still not a proper fix.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
if you take a good look at most "heavy" starting app, like the most famous games, they all do it... it does not make your app less professional... and gives the user something visual to "occupy" his time waiting for the app to start
 
Upvote 0
Top