Thomas Oo
Thomas Oo

Reputation: 389

Common practices for splash screens

I have a "splash screen" in the sense that when I launch my app, a dummy activity splashActivity which has no UI is launched. In this activity, I validate some settings and if they are valid, I show the main view. If they are not valid, I show the login view.

The implementation of this makes sense and I kind of get the idea of a dummy splash screen to handle the logic of showing which activity.

But my question comes from the fact that the transition from launch to the intended activity is abrupt and not smooth. I notice that the screen goes white, and then black, and then goes to my intended activity. Is there a way to make this transition smoother? Maybe this dummy activity approach is not correct? Coming from iOS development, we have an AppDelegate class which handles this logic before any view is displayed and the transition is quite smooth.

TLDR: How do should I approach starting which activity based on some logic? In a dummy activity like I have now, or is there another way? If using dummy activity, how do I make the transition as smooth as possible.

Upvotes: 0

Views: 272

Answers (1)

hifromantal
hifromantal

Reputation: 1764

how do I make the transition as smooth as possible.

Simple, just add a flag to your intent like this:

Intent newIntent = new Intent(getBaseContext(), OtherActivity.class);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(newIntent);

Or override the pending transition right after starting the new activity and before any other lifecycle calls:

overridePendingTransition(0, 0);

How do should I approach starting which activity based on some logic? In a dummy activity like I have now, or is there another way?

To be honest I would not use 2 activities but compensate with one main activity and multiple fragments (say, a login and a content fragment) to accommodate your needs. You can read more about Fragments here.

Upvotes: 1

Related Questions