1

How do I add a welcome picture to my app? A splash activity? Can someone explain how it works. I work with Android. MT manager It is an Android Mobile APK. I would like to see my welcome picture for 1-3 seconds when you start my app. How i do this?

1 Answers1

2

First you must create a layout for the applocation start (welcome screen) or (splash screen) and add what ever you want inside it, In my case I will call it "splash_layout", And then add this codes to your Main Activity


And it's done like this :

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

import androidx.appcompat.app.AppCompatActivity;



public class MainActivity extends AppCompatActivity {

int seconds_in_millis = 2000 ;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // here the welcome screen will show
    setContentView(R.layout.splash_layout);

    // this code makes the main screen shows after 2 seconds
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            setContentView(R.layout.activity_main);
        }
    },seconds_in_millis) ;
}


}

finally , every 1000 millis = 1 second.

a7d.24_
  • 170
  • 1
  • 12