My application is composed by a few activity.
Activity A is my main menu with some icons. This Activity can launch depending on which icon you press: Activity B,C,D,
Instead of ActivityA
, consider using wrapper activity to be called from launcher. You will eliminate a need for checking for ACTION_MAIN. Also you can store target activity name in preferences and use it to directly start your target activity via different intent signature:
public Intent (String action)
<activity class=".StartActivity" android:label="...">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity class=".ActivityA" android:label="...">
<intent-filter>
<action android:name="mypackage.ActivityA" />
</intent-filter>
</activity>
And in StartActivity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
String action = settings.getString("Activitypref","mypackage.ActivityA");
Intent intent = new Intent(action);
startActivity(intent);
....
}
You may need to fiddle around little bit to get it right.