0

Can not seem to find a guide that helps me create a splash screen for my android project done in android studio.

(I am working on a mac)

I can not find where to add a new activity so I can create the splash screen.

Edit: Can not find from the areas I was told to try: photos below SecondEDIT: This is a React-Native Project

Picture 1

picture2

Dominic Gozza
  • 81
  • 1
  • 1
  • 9

2 Answers2

0

You can do it like this:

enter image description here

Then set the new activity as the launcher activity and using a handler, set the next activity after a delay:

 new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent nextIntent = new Intent(mContext, HomeActivity.class);
            startActivity(nextIntent);
            finish();
        }
    }, 1000); //1000ms = 1second
MichaelStoddart
  • 5,571
  • 4
  • 27
  • 49
0

Just create a class in some of your package, create a layout file for that and add it to mainfest under application tag with tag and you can get the Splash type functionality in following way:

public class SplashActivity extends AppCompatActivity {

private static final long SPLASH_SCREEN_DELAY = 2000;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    CountDownTimer countDownTimer = new CountDownTimer(SPLASH_SCREEN_DELAY, 1000) {
        @Override
        public void onTick(long l) {

        }

        @Override
        public void onFinish() {

            User user = GeneralUtils.getRegisteredUser(SplashActivity.this);
            if (user == null || user.getUserId() == null) {
                Intent intent = new Intent(SplashActivity.this, WalkThroughActivity.class);
                startActivity(intent);
            } else {
                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(intent);
            }

            SplashActivity.this.finish();

        }
    };

    countDownTimer.start();
}

}

Shivam
  • 492
  • 5
  • 18