Skip to content Skip to sidebar Skip to footer

Clear Backstack / History Navigationdrawer Item Selected

In the MainActivity I have the NavigationDrawer which looks like this: private void displayView(int position) { ListFragment listFragment = null; switch (position) {

Solution 1:

Use of android.support.v4.content.IntentCompat like this:

Intent intent = IntentCompat.makeRestartActivityTask(newComponentName(DrawerActivity.this, Tracksfragment.class));
startActivity(intent);

Solution 2:

You can set following flags in the intent while starting another activity:

    Intent intent = newIntent(this, MainActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    startActivity(intent);

Hope this is what you were looking for.

Post a Comment for "Clear Backstack / History Navigationdrawer Item Selected"