gpt4 book ai didi

android - 在 Android 中单击主页按钮时更改 bool 值

转载 作者:行者123 更新时间:2023-11-29 22:01:08 26 4
gpt4 key购买 nike

我试图仅在按下主页按钮时更改 bool 值。谁能告诉我解决方案?

最佳答案

onUserLeaveHint() :

Called as part of the activity lifecycle when an activity is about to go into the background as the result of user choice. For example, when the user presses the Home key, onUserLeaveHint() will be called, but when an incoming phone call causes the in-call Activity to be automatically brought to the foreground, onUserLeaveHint() will not be called on the activity being interrupted. In cases when it is invoked, this method is called right before the activity's onPause() callback.

onUserLeaveHint() 中使 bool 变量为真:

 @Override
public void onUserLeaveHint() {
super.onUserLeaveHint();
//make Boolean true here because this method first
//called when user press home key
}

关于android - 在 Android 中单击主页按钮时更改 bool 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11897584/

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