ANDROID:$ P $后活动状态pssing后退按钮

编程入门 行业动态 更新时间:2024-10-25 18:32:04
本文介绍了ANDROID:$ P $后活动状态pssing后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

想象一下,你有以下一系列活动:

Imagine you have the following sequence of activities:

Activity A -> Activity B -> Activity C

当你在活动C,pressing本机返回按钮,带您到活动B.现在有什么活动C的状态呢?它仍然在内存中,或已经完成了吗?

When you are on Activity C, pressing the native back button, takes you to Activity B. Now what is the state of Activity C? Is it still in memory or it has been finished?

如果它仍然在内存中,有没有办法恢复的活动?除了在开始本次活动的另一个实例...

If it is still in the memory, is there a way to resume the activity? Other than starting another instance of this activity...

我要补充一点,这就是你不使用任何标志,包括标准的情况下: FLAG_ACTIVITY_CLEAR_TOP

I should add that this is the standard case where you do not use any flags including: FLAG_ACTIVITY_CLEAR_TOP

推荐答案

您可能要考虑阅读的官方文档。

更具体的回答你的问题的一部分:

More specifically the part that answers your question:

当用户presses后退按钮,当前的活动是从堆栈的顶部(活性被破坏)和previous活动恢复弹出(其UI的previous状态恢复)。

When the user presses the Back button, the current activity is popped from the top of the stack (the activity is destroyed) and the previous activity resumes (the previous state of its UI is restored).

现在你的第二个问题......你可以继续阅读同一页面...

Now for your second question… you can keep reading the same page…

当你开始一个活动,你要提出它的一个现有实例(而不是在后面堆栈的顶部创建一个新的实例)

when you start an activity, you want to bring forward an existing instance of it (instead of creating a new instance on top of the back stack)

所以,如果你看的......你会发现...

So if you read that… you will find…

您可以做这些事情多了,在属性  清单元素并与意图传递给标志  startActivity()。

You can do these things and more, with attributes in the manifest element and with flags in the intent that you pass to startActivity().

在这方面,主要属性可以使用是:

In this regard, the principal attributes you can use are:

taskAffinity  launchMode  allowTaskReparenting  clearTaskOnLaunch  alwaysRetainTaskState  finishOnTaskLaunch

taskAffinity launchMode allowTaskReparenting clearTaskOnLaunch alwaysRetainTaskState finishOnTaskLaunch

和可以使用的主要意图标志是:

And the principal intent flags you can use are:

FLAG_ACTIVITY_NEW_TASK  FLAG_ACTIVITY_CLEAR_TOP  FLAG_ACTIVITY_SINGLE_TOP

FLAG_ACTIVITY_NEW_TASK FLAG_ACTIVITY_CLEAR_TOP FLAG_ACTIVITY_SINGLE_TOP

更多推荐

ANDROID:$ P $后活动状态pssing后退按钮

本文发布于:2023-10-24 08:53:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523495.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   状态   ANDROID   pssing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!