I'm using the NavigationView drawer in my app. I'm trying go back to the previous Fragment if the user press back button. This code works well:
@Override
public void onBackPressed() {
FragmentManager fm = getSupportFragmentManager();
Fragment fr = fm.findFragmentById(R.id.flContent);
if (fm.getBackStackEntryCount() > 0 ) {
fm.popBackStackImmediate();
}
else {
finish();
}
}
But my NavigationView doesn't change. How can I update the NavigationView state (check the correct fragment, change title, and so on), so it can reflect the changes in my app?