White screen before splash screen startup

Asked

Viewed 331 times

1

I created a Splash Screen that works normally, but when opening the application instead of directly entering Splash, it runs a white screen.

Splash.xml

<?xml version="1.0" encoding="utf-8"?>

<ImageView
    android:id="@+id/splash"
    android:layout_width="154dp"
    android:layout_height="217dp"
    android:background="@drawable/logo" />

Class

package empresa.example.easyfood;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {
    //Timer da splash screen
    private  static  int SPLASH_TIME_OUT = 3000;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        new Handler().postDelayed(new Runnable() {
            /*
             * Exibindo splash com um timer.
             */
            @Override
            public void run() {
                // Esse método será executado sempre que o timer acabar
                // E inicia a activity principal
                Intent i = new Intent(SplashActivity.this, CadastroLogin.class);
                startActivity(i);

                // Fecha esta activity
                finish();
            }
        }, SPLASH_TIME_OUT);
    }
}

How do I take white screen?

2 answers

1

If Splashactivity is Activity LAUCHER, this is probably the device that can have more modest hardware, and is loading the app.

To check if Splashactivity is Activity Laucher (initial), just open the Androidmanifest.xml file and see if the Activity annotation contains the attribute below:

<activity android:name=".SplashActivity ">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

Watch out for items within the tag Intent-filter:

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

They define that Activity is the initial and that it runs when the app starts.

If Splashactivity is in fact the Initial Activity, then the white screen is the same app load. If not, make Splashscreen the start by acidifying the above content in its Internet filter tag in the Android Manifest file, and delete whatever Activity was like Laucher before.

1

You can set the color of the window in your style file

 <style name="AppThemeDefault" parent="Theme.MaterialComponents.Light.NoActionBar">
   ...
    <item name="android:windowBackground">@color/cor</item>
    <item name="android:statusBarColor">@color/cor</item>
   ...
</style>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.