fi - Anand Dubey
fi - Anand Dubey

Reputation: 89

Can we change the launcher activity dynamically after launching the app

My requirement is to decide which activity should be launched bt at runtime. For example, if user is logged in then Activity A should be launched else Activity B should be launched. I have also tried using the logic that is saving the data in preference and then checking whether the user is present or not and den making an intent launch accordingly. But this approach gives a slight lag at the start while checking the user is present or not in the preference. Can activity-alias can help in this scenario?

Upvotes: 0

Views: 206

Answers (2)

Kinjal Rathod
Kinjal Rathod

Reputation: 549

In most of the application developers use a splash screen to perform certain tasks. In your case, you can add a splash screen for a few seconds(2 or 3 sec) in which you can check the login status of the user, from shared preference, which will decide which activity needs to be launched next.

Upvotes: 1

Gabe Sechan
Gabe Sechan

Reputation: 93559

The normal solution for this is to check if the user is logged in at the top of onCreate of the login activity, and if so immediately start activity B, finish itself, then return.

Upvotes: 0

Related Questions