When I click the back button It goes to previous action rather than Previous Activity
what is want to do is this : 1.Activity next-> 2.Activity2 next-> 3.DialogFragment(select user from DialogFragment) next-> Activity2 (with selected user) backPressed-> Activity.
what i am at is : 1.Activity next-> 2.Activity2 next-> 3.DialogFragment(select user from DialogFragment) next-> Activity2 (with selected user) backPressed-> 5.DialogFragment backPressed->Activity
Scenario is: When i open this Activity and selecting user from dialogFragment from OnClick Event as shown in below Image:
after selecting user screen is:
when i click the back button on Top right Corner it again opens the same fragment rather than opening previous activity.. I have Tried lot of ways but Could not find solution. Please Help.
]3
my code:
//
Back button in toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitleTextColor(getResources().getColor(R.color.o2htextOne));
getSupportActionBar().setDisplayShowTitleEnabled(false);
final Drawable upArrow = getResources().getDrawable(R.drawable.back_arrow);
upArrow.setColorFilter(getResources().getColor(R.color.o2htextOne), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);
{
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Intent intent=new Intent();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId()==android.R.id.home)
{
finish();
}
return true;
}