Well, I have the following doubt, can you give finish()
to fragment
that have already passed?
The case is as follows:
I have some screens in sequence where I use for the buddy choose the snack, then he chooses the bread, clicks next, chooses the type of steak clicks next, chooses if he wants salad clicks next, all these times he can come back and choose the product again, but in the last screen when it clicks on sell, if it comes back it should be redirected to the first page, in the case of my example the page to choose the bread.
I tried to give finish()
in the last fragment
, but it returns in the previous one. In case I can not clear the whole list of navigation because there are other restaurants to have access, so I must return in the option (in the example) to choose bread.
They are basically 6 activity
in which I can navigate and come back in the choice of bread
My attempt was to put in the onBackPressed()
event like this:
@Override
public void onBackPressed()
{
try{
super.onBackPressed();
Intent intent = new Intent(getApplicationContext(),FragmentCardapio_.class);
startActivity(intent);
}catch(Exception e){
MessageUtil.showError(getApplicationContext(), e.getMessage());
}
}
But of the error!
android.view.WindowManager $ BadTokenException: Unable to add window - token null is not for an application