Method setDrawerListener is deprecated

Use addDrawerListener() instead.


Replace setDrawerListener

drawerLayout.setDrawerListener(actionBarDrawerToggle);

with addDrawerListener

drawerLayout.addDrawerListener(actionBarDrawerToggle);

example

  DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                    this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
            assert drawer != null;
            drawer.addDrawerListener(toggle);
            toggle.syncState();

            NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
            assert navigationView != null;
            navigationView.setNavigationItemSelectedListener(this);

Replace:

drawer.setDrawerListener(...);

with

drawer.addDrawerListener(...);

public void setDrawerListener(DrawerLayout.DrawerListener listener) Sets a listener to be notified of drawer events.

Note that this method is deprecated and you should use addDrawerListener(DrawerLayout.DrawerListener) to add a listener and removeDrawerListener(DrawerLayout.DrawerListener) to remove a registered listener.