退出活动导致重新启动时不出现对话框

发布于 2024-11-14 14:57:59 字数 899 浏览 8 评论 0原文

我一直在研究这个问题,但似乎无法弄清楚。我有一个简单的应用程序,带有一些普通视图和 GL 表面视图,我使用 onCreateDialog() 创建了一些对话框,一切看起来都很好。

@Override
protected Dialog onCreateDialog(int id)
{
     super.onCreateDialog(id);

     Dialog m_Dialog = null;

     // help dialog
     if (id == HELP_DIALOG)
     {
        m_Dialog = new Dialog(this);
        m_Dialog.setContentView(R.layout.help_dialog);
        m_Dialog.setTitle("Instructions - Press BACK to close");
     }
 }

但是,如果我使用 home 退出应用程序,然后返回应用程序,对话框将不再出现,但屏幕会变暗,就像正在显示对话框一样。即使对话框没有显示,我也会收到对 onPrepareDialog() 的调用,我尝试了一些操作,例如从对话框中调用 show() 。如果我随后切换到 GL 表面视图并返回对话框再次工作,情况会变得有点奇怪。我正在使用 ViewAnimator 在视图之间切换。我很确定我正在正确处理生命周期,超越 onPause() / onResume()

@Override
protected void onResume()
{
    super.onResume();
    m_Sensors.StartSensors();       
    m_GameThread.Pause(false);
    glSurface.onResume();
}

一如既往,感谢您的帮助。

I've been poking around at this problem and I can't seem to figure it out. I have a simple app with a few normal views and a GL surface view, I make a few dialog boxes using onCreateDialog() and everything seems fine.

@Override
protected Dialog onCreateDialog(int id)
{
     super.onCreateDialog(id);

     Dialog m_Dialog = null;

     // help dialog
     if (id == HELP_DIALOG)
     {
        m_Dialog = new Dialog(this);
        m_Dialog.setContentView(R.layout.help_dialog);
        m_Dialog.setTitle("Instructions - Press BACK to close");
     }
 }

However if I use home to exit the app then go back into the app the dialogs no longer appear, however the screen dims as if the dialog was being displayed. I am getting the call to onPrepareDialog() even when the dialog does not show, I tried some things in there like calling show() off of the dialog. It gets a bit more strange, if I then switch to my GL surface view and back the dialogs work again. I am using a ViewAnimator to switch between my views. I am pretty sure I am handling the lifecycle correctly, over riding onPause() / onResume()

@Override
protected void onResume()
{
    super.onResume();
    m_Sensors.StartSensors();       
    m_GameThread.Pause(false);
    glSurface.onResume();
}

As always, thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝梦月影 2024-11-21 14:57:59

我还没有尝试在 Android 上使用 GL,但我最近自己也经历过一些主页按钮/重新打开应用程序的奇怪现象 - 就我而言,它与以下问题有关,您可能想检查一下:

< a href="http://code.google.com/p/android/issues/detail?id=5277" rel="nofollow">http://code.google.com/p/android/issues/detail? id=5277

http://code.google.com/p/android/issues/detail?id =2373

希望它能帮助您走上正轨。

I haven't tried working with GL on android, but I have experienced some home button/re-open app weirdness myself recently - in my case it turned out to be connected to the issues below, which you might want to check out:

http://code.google.com/p/android/issues/detail?id=5277

http://code.google.com/p/android/issues/detail?id=2373

Hope it can help you get on the right track.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文