well, so, that´s my problem.
I need, when the user press the back bottom, to delete the stack of all activities opened:
@Override
public void onBackPressed(){
Intent i = new Intent(context, CrisolMainApp.class);
i.putExtra(CrisolMainApp.CERRAR_APP, true);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
The point is that this is working with most of my phones, but yesterday I tried with a Samsung Galaxy Mini (android 2.3.3) and it is not working!! It is not deleting the stack of activities.
Anyone knows why?
EDIT: I was checking on doc, and I found out that the "Intent.FLAG_ACTIVITY_CLEAR_TASK" was added on API 11(my Samsung Galaxy Mini is working for Android 2.3.3, so, API 10).......I don´t know, but I guess that´s the problem.
Anyone knows how can I make it work the same way for API less than 11?
I was trying by adding these flags and it is not working either:
@Override
public void onBackPressed(){
Intent a = new Intent(this, CrisolMainApp.class);
a.putExtra(CrisolMainApp.CERRAR_APP, true);
a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
a.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(a);
finish();
}
and I also tried:
@Override
public void onBackPressed(){
Intent a = new Intent(this, CrisolMainApp.class);
a.putExtra(CrisolMainApp.CERRAR_APP, true);
a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
a.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(a);
finish();
}
A simple fix should be adding the xml attribute android:noHistory="true"
to all of your activities, which will mean that as soon as the user leaves that Activity, it will be gone, and no back stack will be stored
You do not finish the activity.
Intent i = new Intent(context, CrisolMainApp.class);
i.putExtra(CrisolMainApp.CERRAR_APP, true);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
finish();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With