安卓避免OnResume [英] Android avoid OnResume

查看:429
本文介绍了安卓避免OnResume的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个Acivity基础的应用程序,它是这样的工作流程 MainActivity 的ListView 的DetailView 。当onResume事件触发,需要调用MainActivity。无需另外两个活性

I have 3 Acivity based application, It's work flow like this MainActivity ListView and DetailView. when onResume event trigger , need to call MainActivity. without going to other two activity.

有什么办法叫 MainActivity 时,onResume事件触发?

Is there any way to call MainActivity when onResume event trigger?

感谢您

推荐答案

您可以设置安卓clearTaskOnLaunch =真正的属性您MainActivity在AndroidManifest.xml文件。请参见这里找到原因和更多的细节。我觉得这是最便捷的方式,以满足您的需求。

You can set the android:clearTaskOnLaunch="true" attribute for you MainActivity in the AndroidManifest.xml file. See here to find why and more details. I think this is the most convenient way to meet your demand.

编辑: 我只是测试,发现当您退出应用程序,并从应用程序的抽屉启动的应用程序,这仅适用(不长preSS回家,然后选择应用程序)。

I just tested and found this only works when you exit the app and launch the app from the app drawer(NOT long press on HOME and select the app).

如果你想永远把根系活力的前面,无论你什么时候重新启动应用程序,或从最近的画面。你可以声明机器人:launchMode =singleTask的根系活力,在这里,MainActivity

If you want to always bring the root activity to the front, no matter when you re-launch the app or from the recent screen. You can declare "android:launchMode="singleTask" for the root activity, here, the MainActivity.

这篇关于安卓避免OnResume的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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