How to avoid black screen in android while my app is loading?
Asked Answered
I

4

9

How to avoid black screen in android while my app is loading ? I have removed all things from onCreate to AsyncTask but still I have black screen at the beginning. My default ( first ) activity is Main and if there is one parameter I momentarily load Personal activity withou showing Main, otherwise I show Main activity. Can anyone suggest me solution ? I tried with http://blog.iangclifton.com/2011/01/01/android-splash-screens-done-right/ but it doesn't help.

Illuminati answered 11/1, 2012 at 10:15 Comment(2)
Post some code - it might help or we are just guessing...Planometer
see the solution here : developer.android.com/topic/performance/vitals/…Thalia
R
20

i'm not sure.

but, Try this in Manifest inside your activity

android:theme="@android:style/Theme.Translucent" 

Or

android:theme="@android:style/Theme.Light"

I have seen a good solution about splash screen... hope it useful

https://mcmap.net/q/1169873/-android-splashscreen-while-asynctask-is-running

Romulus answered 11/1, 2012 at 10:29 Comment(3)
I was struggling for so long. This solved my issue. Just adding the line in Manifest did the trick. Thanks April.Cassock
thanks, this give me an idea to make a custom theme like flash and it solved my problem. For those who are looking for same answer this is how i do it It worked for me hope it help you guys too. In style.xml <style name="MySplashTheme" parent="AppBaseTheme"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@drawable/splash_image</item> </style> Manifest file in activity tag android:theme="@style/MySplashTheme"Irrelevant
But there is a problem with this solution, it locks your screen orientation to portrait.. ;(Herold
J
14

Add below line in your android style.xml file in style tag .

 <item name="android:windowDisablePreview">true</item>

Complete code :

 <style name="AppBaseTheme" parent="android:Theme.Light.NoTitleBar">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
    <item name="android:windowDisablePreview">true</item>
</style>
Jaws answered 9/4, 2015 at 9:38 Comment(1)
My app finished with thisInfamous
M
3

Optimize ur code,try to reduce code from onCreate(),this was issue faced by me i solved it by reducing code in onCreate().

Best of Luck

Mcquiston answered 11/1, 2012 at 10:29 Comment(0)
B
1

Since you have cleared out your onCreate() and assigned your initialization tasks to a worker thread, the fact that your screen nonetheless remains dark for a while after your app is launched is probably due to the complexity of the graphics in your initial display (rather than to your initialization code, which is probably model-related, rather than view-related).

The solution that you say worked for you is to use a visible background as your theme. I'm glad that you found that to be adequate, but for some purposes a more specific (e.g., logo / app name) splash screen (which displays quickly because it uses much simpler graphics) would be more desirable.

Please see the answer linked below for a detailed description (with sample code) of how a splash screen that displays quickly can be implemented:

Create a true splash screen

This also discusses the approach that you have accepted above.

Byronbyrum answered 20/9, 2012 at 7:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.