gpt4 book ai didi

android - Android 上的后退按钮/后退键会触发哪些操作?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:51:14 25 4
gpt4 key购买 nike

我真的很困惑。我读过后退按钮

我觉得onPause()应该是对的。但这是一个副作用,因为 Activity 进入了后台。我什么也没找到in the docs.但也许我忽略了一些东西。

有人可以向我解释后退按钮应该以编程方式做什么吗?一些引用也很好。 :-)

最佳答案

I have read that the back button calls onDestroy(), can close up your currently-running activity, calls onPause()

这三个都是正确的。

I found nothing in the docs.

引用 the Android documentation :

When the user presses the BACK key, 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).

详细来说,如果没有其他东西会消耗 BACK 按钮按下(例如,打开的选项菜单),您的 Activity 将通过 onBackPressed() 调用.此调用的默认实现调用 finish()。这将使您的 Activity 从运行状态变为销毁状态,依次调用 onPause()onStop()onDestroy(),如事件流程图所示:

enter image description here

关于android - Android 上的后退按钮/后退键会触发哪些操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7290019/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com