Maggie
Maggie

Reputation: 8101

android choose between two starting activities

I need to choose between two starting (Main) activities based on some stored data. Logic I am trying to achieve is something look like:

if (data == something) showActivity1();
else showActivity2();

Is there a way to declare something like this in manifest? Multiple

 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.LAUNCHER" />  tags?

Or is there a point in application where this code would be suitable? I was thinking of creating one activity, and then just set them different content views and handle logic accordingly, but these two activities are very very different, so it would result in a lot of unconnected code in one file. Thanx in advance.

Upvotes: 2

Views: 918

Answers (1)

kingori
kingori

Reputation: 2616

If you set multiple MAIN & LAUNCHER tag, multiple activities appear in your application list. So, that's not what you want.

My recommendation is like this...

  1. make an transparent activity( works as facade )
  2. judge which activity to start
  3. start target activity and finish facade activity

Upvotes: 2

Related Questions