Navigation Drawer icon in action bar not working

Solution for Navigation Drawer icon in action bar not working
is Given Below:

The Action bar icon for navigation drawer not displaying the menu, but when I swipe my finger over the activity screen from the left edge, then the menu appears which means there is nothing wrong with the actual menu. Just the action bar icon for navigation drawer not working. I used the default navigation drawer activity and then modified it.

The problem is in the onOptionsItemSelected method. If I comment that method, then navigation drawer icon works properly. But if I do not remove that method, then navigation icon dose not working.

Please help me.

Below is the code of that activity.

    public class MainDashboard extends AppCompatActivity {
    FirebaseAuth firebaseAuth;
    FirebaseUser firebaseUser;
    Context context;
    DrawerLayout drawerLayout;
    NavigationView navigationView;
    private AppBarConfiguration mAppBarConfiguration;
    private ActivityMainDashboardBinding binding;

    protected void onCreate(Bundle savedInstanceState) {

        firebaseAuth = FirebaseAuth.getInstance();
        firebaseUser = firebaseAuth.getCurrentUser();
        context =MainDashboard.this;

        binding = ActivityMainDashboardBinding.inflate(getLayoutInflater());

        DrawerLayout drawer = binding.drawerLayout;
        NavigationView navigationView = binding.navView;

        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.
        mAppBarConfiguration = new AppBarConfiguration.Builder(
        NavController navController = Navigation.findNavController(this,;
        NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
        NavigationUI.setupWithNavController(navigationView, navController);

private void showLogoutDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage("Are you sure want to logout?").setPositiveButton("Yes, Logout.", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //logout here.
                firebaseAuth.signOut();//end the session
                startActivity(new Intent(getApplicationContext(),MainActivity.class));
        }).setNegativeButton("No!", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
        AlertDialog alertDialog = builder.create();;
//Inflate Option menu 
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        int item_id = item.getItemId();
        if(item_id ==
            startActivity(new Intent(getApplicationContext(),UserProfile.class));
        else if(item_id ==
        return true;

    public boolean onSupportNavigateUp() {
        NavController navController = Navigation.findNavController(this,;
        return NavigationUI.navigateUp(navController, mAppBarConfiguration)
                || super.onSupportNavigateUp();