sennin
sennin

Reputation: 8972

Android Activity choose

I need to choose if I should run one activity or another depends on authorization. If you have no account in AccountManager I want to show RegistrationAcitivity in other situation I want to show LoginActivity. What is the best pattern to do that? Where I need to put the code which is checking that? In one of those activities?

Upvotes: 0

Views: 88

Answers (2)

MAC
MAC

Reputation: 15847

You can check the condition is user is already register then move to AccountManager .

Intent intent = new Intent(this,AccountManager.class);
startActivity(intent);

if not then redirect him to RegistrationAcitivity

Intent intent = new Intent(this,RegistrationActivity.class);
startActivity(intent);

For that you can set flags.

or store data either in SharedPreferences or Database

Upvotes: 1

gandharva
gandharva

Reputation: 691

You can put the code in Registration Activity, check for accounts there and if available redirect him to login activtiy

Upvotes: 0

Related Questions