Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Whenever I launched my app, it displayed a blank screen for a few seconds before displaying the splash screen.

Now it displays a purple background(from my drawable) for a few seconds before displaying the splash screen(after I added the "what I tried code"). What I want to do is to completely remove the screen that displays before the splash screen. Like I want the splash screen to be displayed immediately I open the app, please how can I fix this?
Here's my code:
public class MainActivity extends AppCompatActivity {

    Animation topAnim, bottomAnim;
    ImageView image;
    TextView logo, slogan;

    protected void onCreate(Bundle savedInstanceState) {
        View decorView = getWindow().getDecorView();
// Hide the status bar.
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;

        topAnim = AnimationUtils.loadAnimation(this,R.anim.top_animation);
        bottomAnim = AnimationUtils.loadAnimation(this,R.anim.bottom_animation);

        image = findViewById(;
        logo = findViewById(;
        slogan = findViewById(;


        int SPLASH_SCREEN = 5000;
        new Handler().postDelayed(new Runnable() {
            public void run() {
                Intent intent = new Intent(MainActivity.this, HomeActivity.class);
        }, SPLASH_SCREEN);

<resources xmlns:tools="">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">#0347F4</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowBackground">@drawable/purple_background</item>
    <item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="o_mr1">shortEdges</item>


What I have tried:

I tried to fix it adding this to the styles.xml:
<item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowBackground">@drawable/purple_background</item>
David Crow 8-Apr-21 15:06pm    
Using a timer is always a bad idea. Instead, create a "splash screen" activity whose theme is the graphic you want to display. In that activity's onCreate() method, start the actual main activity, like:
startActivity(new Intent(SplashScreenActivity.this, MainActivity.class));
Don't forget to adjust the two activities in the manifest file. The action and category should be moved from the main activity to the "splash screen" activity.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900