android - Navigate via back-button from child fragment back to parent activity -
i have main activity , 2 fragments. in main activity have navigation drawer navigates through fragments. handle button pressed this:
@override public void onbackpressed() { if (getfragmentmanager().getbackstackentrycount() > 0) { getfragmentmanager().popbackstackimmediate(); } else { super.onbackpressed(); } }
after navigating between 2 fragments, when hit button, last fragment backstack. however, navigating fragment fragment should not possible.
more clarity:
i have 1 activity (with navigation drawer) , 2 fragments. navigation drawer can go both fragments many times want. when hit button, want go main_activity.xml
.
when navigate through activities, best way use intent
s (if understood question):
intent intent = new intent(this, mainactivity.class); startactivity(intent);
Comments
Post a Comment