gpt4 book ai didi

android - 注销对话框错误 : token android. os.BinderProxy@4276c0e8 无效;你的 Activity 在运行吗

转载 作者:行者123 更新时间:2023-11-29 19:42:59 25 4
gpt4 key购买 nike

我有一个登录屏幕,登录成功后,它会完成并显示 AppActivity。如果用户从应用程序注销,则再次显示登录屏幕,完成 AppActivity。但是,当登录屏幕在用户注销后尝试显示对话框时,我遇到了如下所示的错误:

android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@4276c0e8 is not valid; is your activity running?

如果用户成功登录应用程序,LoginScreen 完成,显示 AppActivity:

Intent intent = new Intent(LoginScreen.this, AppActivity.class);
startActivity(intent);
finish();

如果用户点击注销按钮,AppActivity 完成,显示 LoginScreen:

Intent intent = new Intent(AppActivity.this, LoginScreen.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();

最佳答案

当您为不再存在的上下文显示对话框时,可能会发生这种情况。常见情况 - 如果“显示对话框”操作在异步操作之后进行,并且在该操作期间原始 Activity (即对话框的父 Activity )被销毁。

这可能类似于 here .希望对您有所帮助。

关于android - 注销对话框错误 : token android. os.BinderProxy@4276c0e8 无效;你的 Activity 在运行吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38298887/

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