user820913 user820913 - 1 year ago 92
Android Question

Showing logo 3 seconds before loading mainActivity

I want to make a logo (an own activity)show in an own activity 3 seconds before the main activity loads, when starting my android app. Which is the simplest approach for doing this?

I have searched through this forum, I could only find one answered question around this topic, but unhappily it was unusefull for me.

Answer Source

I think what you're referring is how to implement a Splash screen,

Create a new empty activity, I'll call it Splash for this example;

public class SplashScreen extends Activity {

    // Sets splash screen time in miliseconds
    private static int SPLASH_TIME = 3000;

    protected void onCreate(Bundle savedInstanceState) {

        new Handler().postDelayed(new Runnable() {

            public void run() {

                // run() method will be executed when 3 seconds have passed

                //Time to start MainActivity
                Intent intent = new Intent(Splash.this, MainActivity.class);
                startActivity(intent );

        }, SPLASH_TIME);


Make sure you've set Splash activity as the launcher activity in your Manifest file :


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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download