In my menu I have some items. Home is an item of it that I want to be root of my application and whenever user clicks on it, Android clear stack and then come back to main screen.
This is my code:
menu.setOnItemClickedListener(new MenuClickedListener() {
public void eventOccured(int id) {
Intent intent = null;
switch(id) {
case 1: intent = new Intent(context, More.class); break;
case 2: intent = new Intent(context, FavoriteScreen.class); break;
case 3: intent = new Intent(context, VideoShowList.class); break;
case 4: intent = new Intent(context, ShoppingList.class); break;
case 5: intent = new Intent(context, MainScreen.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
break;
}
if(intent != null)
context.startActivity(intent);
}
});
Menu works fine but it seems flag doesn't work because from Home screen, i go to second and third screen then i click on Home item of menu and come back to home screen. Now, when i click on back button, i go to third screen, second screen and Home screen.
I have designed this menu as widget in order to setup it one time and reuse it on all of my screens.
Any suggestions would be appreciated. Thanks.