android / architecture-components-samples

Samples for Android Architecture Components.
https://d.android.com/arch
Apache License 2.0
23.47k stars 8.29k forks source link

Navigation Components back stack not working with java code #1046

Open sunnyeverestek opened 2 years ago

sunnyeverestek commented 2 years ago

NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.base_container);

    if (navHostFragment != null) {
        navController = navHostFragment.getNavController();
        NavigationUI.setupWithNavController(viewBind.bottomNav, navController);

        setSupportActionBar(viewBind.appBar.toolbar);
        appBarConfiguration =  new AppBarConfiguration.Builder(R.id.discoveryFragment,R.id.analyticsFragment
        ,R.id.feedFragment,R.id.notificationFragment).build();

        NavigationUI.setupActionBarWithNavController(this,navController,appBarConfiguration);
    }