I created a base activity that has a menu, this menu will open other activities in the application.
public class BaseActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//Intent i = new Intent("com.app.Activity1");
//startActivity(i);
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.icon: Intent i1 = new Intent("com.app.Activity1");
startActivity(i1);
break;
case R.id.text: Intent i2 = new Intent("com.app.Activity2");
startActivity(i2);
break;
case R.id.icontext: Intent i3 = new Intent("com.app.Activity3");
startActivity(i2);
break;
}
return true;
}
}
All activities extend this base activity, so when you press the menu button, the menu pops up and you can select an activity.
However, lets say I use the menu to go to activity A. Once I'm in activity A I can use the menu to go to Activity A again. I can do this X times, but now the back button will go back to the same activity X times.
How can I tell if the activity is already running so a user can't keep opening the same activity?
Or rather, would you suggest I disable the menu item once in activity A?
Thanks for your input. Sorry if this seems like a trivial question.