Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK不工作的Android [英] Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK not working Android
问题描述
很好,所以,that's我的问题。
我需要的,当用户preSS后底,删除所有活动的堆栈开:
@覆盖
公共无效onBack pressed(){
意图I =新意图(背景下,CrisolMainApp.class);
i.putExtra(CrisolMainApp.CERRAR_APP,真);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(ⅰ);
}
问题的关键是,这正与我的大部分手机,但昨天我试着用三星Galaxy迷你(安卓2.3.3),它不工作!它不删除活动的堆栈。
任何人都知道这是为什么?
编辑:我被检查的文档,并且我发现了Intent.FLAG_ACTIVITY_CLEAR_TASK于11 API添加(我的三星Galaxy Mini是工作为Android 2.3.3,因此,API 10)..... ..我知道鸵鸟政策,但是我想that's的问题。
任何人都知道我怎么可以把它的工作方式相同的API小于11?
我是想加入这些标志和它不工作之一:
@覆盖
公共无效onBack pressed(){
意图=新的意图(这一点,CrisolMainApp.class);
a.putExtra(CrisolMainApp.CERRAR_APP,真);
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(一);
完();
}
和我也试过:
@覆盖
公共无效onBack pressed(){
意图=新的意图(这一点,CrisolMainApp.class);
a.putExtra(CrisolMainApp.CERRAR_APP,真);
a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
a.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(一);
完();
}
您可以使用 IntentCompat.FLAG_ACTIVITY_CLEAR_TASK
和进口进口android.support.v4 .content.IntentCompat;
从工作的支持库对API 10
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();
}
You can use IntentCompat.FLAG_ACTIVITY_CLEAR_TASK
and import import android.support.v4.content.IntentCompat;
from support library for work on API 10.
这篇关于Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK不工作的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!