从重建prevent任务管理器在任务最后显示的活动 [英] prevent task manager from recreating last displayed activity in a task

查看:194
本文介绍了从重建prevent任务管理器在任务最后显示的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该方案是:

启动应用程序,启动活动A,定位到B,然后到C preSS home键。 Ç被破坏。调出任务管理器,preSS在我的应用程序的图标。活动C的再创造。我怎样才能让这种行为停止?我想会回去活性的。

launch app, start activity A, navigate to B, then to C press home button. C gets destroyed. Bring up task manager, press on my app's icon. Activity C is being recreated. How can I make this behaviour cease ? What I would like would be to go back to activity A.

我能得到这个最接近的是通过开展活动​​B,C与Intent.FLAG_ACTIVITY_NO_HISTORY。但有了这个标志的问题是,它prevents活动B,C从整个应用程序的生命不断被重新创建(它们应该是可创建一次任务管理器导致用户A)。

The closest I could get to this was by launching activities B,C with Intent.FLAG_ACTIVITY_NO_HISTORY. But the problem with this flag is that it prevents activities B,C from ever being re-created throughout the app's life (they should be creatable once task manager leads user to A).

编辑:观察在Intent.FLAG_ACTIVITY_NO_HISTORY情况下,如果我用这个方法,而不是相同的行为:

same behaviour observed as in Intent.FLAG_ACTIVITY_NO_HISTORY case if I use this approach instead:

class C extends Activity
{
...
    @Override
    protected void onDestroy() 
    {
        // last resort
        finish();
        super.onDestroy();      
                //finish();
    }
}

我无法导航回活动ç一旦它的onDestroy()被调用一次:(

I can not navigate back to activity C once it its onDestroy() has been called once :(

感谢

推荐答案

编辑Manifest.xml文件,并在您不希望指定的活动得到重建这样的:

Edit your Manifest.xml file and specify in the activity you don't want to get recreated this:

android:launchMode="singleTask"

或者根据您的需要使用其他属性。去 这里详细交代。

这篇关于从重建prevent任务管理器在任务最后显示的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆