0
Well I am with the following doubt, has to give finish()
in fragment
who have passed ?
The case is as follows:
I have a few screens in sequence where I use for the comrade to choose the snack, then he chooses the bread, clicks next, chooses the type of the steak clicks next, chooses if you want salad clicks next, all these times he can come back and choose again the product, but on the last screen when he clicks on effective sale, if he returns should be redirected to the first page, in the case of my example the page to choose the bread.
I tried to give a finish()
at last fragment
, but she comes back the previous one. In case I can not clear all navigation list because there are other restaurants to have access, so I should return to the option (in the example) of choice of bread.
Are basically 6 activity
in which I can sail back and forth in the choice of bread
My attempt was to put on the event of onBackPressed()
thus:
@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 error !
android.view.Windowmanager$Badtokenexception: Unable to add window -- token null is not for an application
tried to use
Intent activitquequeroabrir = new Intent(...);
and thenactivitquequeroabrir.startActivity();
?– Armando Marques Sobrinho
yes, I’ll update the question
– Renan Rodrigues
@Armandomarquessobrinho update her
– Renan Rodrigues
In one place talks about Fragments in another in activities. After all are activities or Fragments?
– ramaral
It’s because the first is
fragment
(fragment_caradapio) and the others areactivitys
– Renan Rodrigues
The error is because you are trying to launch an Activity by using in the class Intent that is a Fragment(
FragmentCardapio_.class
).– ramaral
How do you fix it ?
– Renan Rodrigues
opa, now vi, then in case, it would be better to Voce do all of them Fragments, because thus Voce has greater flexibility and a Fragment is also an Activity or works the same with the difference that Voce needs to use a fragmentmanager to call the respective routines, whether with dynamic layout or Static layout, in my view it is easier to handle, except if you really need to have an Activity
– Armando Marques Sobrinho
if in the case Voce is to use Fragment, take the example of navigation draw from android studio, it already opens and navigates between several native Fragments same
– Armando Marques Sobrinho
My problem is not navigating, this attending me very well, what I need is when Face click back, it goes to menu.
– Renan Rodrigues