问题描述
我们构建了一个 Android Launcher,并且在 onDestroy() 和 finish() 中有一些奇怪的行为。根据 the docs 和 this post,isFinishing()
仅在 Activity 上调用 finish() 时才应为真。然而,虽然从未在 MainActivity 上调用 finish(),但在 MainActivity 的 onDestroy() 方法中 isFinishing() 为真。
第一次创建 MainActivity 后,当用户通过 Play Store 安装或卸载应用时,MainActivity 的 onDestroy() 在退出 Play Store 后被调用。这仅在第一次发生,之后按预期调用 onResume() 方法,而不会重新创建 MainActivity。
我正在检查 isFinished() 是否是这样调用的:
@Override
public void finish() {
// (Never called)
super.finish();
Log.i(TAG,"Finish called. " + isFinishing());
}
@Override
public void onStop() {
super.onStop();
// When opening the Play Store app,isFinishing is false here
Log.i(TAG,"onStop called. Finishing: " + isFinishing());
}
@Override
public void onDestroy() {
super.onDestroy();
// When exiting the Play Store app (opening our Launcher),isFinishing is true the first time,// after that onDestroy isn't called anymore.
Log.i(TAG,"onDestroy called. Finishing: " + isFinishing());
}
有人知道为什么在安装/卸载应用程序后第一次调用 onDestroy 吗? 谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)