Set your Intent Flag . it remove activity from top.
Intent crush=new Intent(getApplicationContext(),P.class);
crush.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(crush);
Domanda
Imaginarily, I have a parent activity called 'P'. Mr P has 5 children, called '1','2','3','4','5'.
But the truth in my project is ,
P have 1 as child.
1 have 2 as child.
2 have 3 as child.
and so on.
I travel from P to 1, and from 1 to 2, from 2 to 3, and so on.
The problem is how can i travel from 3 straight to P ? therefore P must be his parent am i wrong?
Here is what i have implemented so far on my back pressed
@Override
public void onBackPressed(){
if (background_tick != null){
if(background_tick.isPlaying())
background_tick.stop();
background_tick.release();
// finish();
}
Intent crush=new Intent(getApplicationContext(),P.class);
startActivity(crush);
//super.onBackPressed();
}
With that code i successfully go to activity P, but when i press 'Back' from P it return to acitivy 3 and i dont want that happen.
Any answer will appreciated guys. greetings from bali.
Soluzione
Set your Intent Flag . it remove activity from top.
Intent crush=new Intent(getApplicationContext(),P.class);
crush.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(crush);
Altri suggerimenti
Uses the Flag
Intent i = new Intent(3.this,P.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);