Android的显示最近的活动重新启动一个应用程序后, [英] Android show last activity after restarting an app

查看:210
本文介绍了Android的显示最近的活动重新启动一个应用程序后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动中号这是主要 活动。我可以访问 b活动活动中号和其他活动ç b活动

I have an Activity M which is the main Activity. I can access an Activity B from Activity M and another Activity C from Activity B.

所以 M - > B - > C

So M -> B -> C.

在我目前在活动ç和preSS在我的设备的底部,(在其中一个让我回到主屏幕按钮。怎么叫这个按钮呢?),然后再次单击我的应用程序图标,它将启动活动中号而不是活动ç,虽然最后表示活动是 C

When I am currently in the Activity C and press the button on the bottom of my device, (the one which brings me back to the home screen. How is this button called anyway? ) and then click on my application icon again, it will start the Activity M instead of Activity C, although the last shown activity was C.

所以 M - > B - > C - >家里通过按钮点击屏幕 - >点击应用程序图标 - > M

So M -> B -> C -> home screen through button click -> click on application Icon -> M

但我要的是 M - > B - > C - >家里通过按钮点击屏幕 - >点击应用程序图标 - > C

But what I want is M -> B -> C -> home screen through button click -> click on application Icon -> C

我希望我的问题是清楚的。有谁知道如何关闭/暂停对应用程序的应用之前显示我的最后一个显示活动的重启的?

I hope my problem is clear. Does anyone know how to show my last shown activity before closing / pausing the application on application restart?

推荐答案

试试这个...

 @Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { 
        // Activity was brought to front and not created, 
        // Thus finishing this will get us to the last viewed activity 
        finish(); 
        return; 
    } 

    // Regular activity creation code... 
} 

这将始终打开从那里的应用程序退出的最后一项活动......

This will always open the last activity from where the app was exited.....

这篇关于Android的显示最近的活动重新启动一个应用程序后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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