android - On home button click(in appbar/toolbar) from next activity, I need same fragment on main activity(which was there before going to next activity) -


i have fragment on main activity gets loaded on click of item nav drawer , on click of list item fragment(main screen) navigate activity. if press device button fragment screen(as expected) if use tool bar , enable the home button saying

getsupportactionbar().sethomebuttonenabled(true); 

i main activity content prior selecting item drawer. have set parent of next activity main activity need fragment loaded when go back.

try this

 @override public boolean onoptionsitemselected(menuitem item) {     int id = item.getitemid();     if (id == r.id.home) {         navutils.navigateupfromsametask(this);     }     return super.onoptionsitemselected(item); } 

you need add getsupportactionbar().setdisplayhomeasupenabled(true); along getsupportactionbar().sethomebuttonenabled(true);