I have a particular situation where, I have a parent Activity
which extends ActionBarActivity
in that Activity
I declare and initialize my DrawerLayout
with all the boiler plate code for implementing a Navigation Drawer
Then to save time I created new Activities
which extend this DrawerActivity
in my code so you can open the navigation drawer in all these activities.
The problem occurs when this happens:
Assume Activities are:
Activity A = [A]
Activity B = [B]
Both extend DrawerActivity
[A] --- Open Drawer and Open --> [B] --- Press Back Button ---> [A]
The Navigation Drawer opens from the Home Button
when you are in [A]
, but when I press the back button from [B]
I can't open the Navigation Drawer from the Home Button
but I can slide out the drawer.
Can someone explain to me what I am doing wrong here, I was wondering if there was an issue with ActionBarDrawerToggle.syncState()
but I tried implementing that everywhere I could and it didn't solve the problem.
Like I mentioned above all the boiler plate code is already written, example:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
switch (id) {
case android.R.id.home:
if (!mDrawerLayout.isDrawerOpen(recyclerView)) {
mDrawerLayout.openDrawer(recyclerView);
mActionBarDrawerToggle.syncState();
} else if (mDrawerLayout.isDrawerOpen(recyclerView)) {
mDrawerLayout.closeDrawer(recyclerView);
mActionBarDrawerToggle.syncState();
}
break;
case R.id.action_logout:
new DeauthorizeTask().execute();
}
return super.onOptionsItemSelected(item);
}