退出活动导致重新启动时不出现对话框
我一直在研究这个问题,但似乎无法弄清楚。我有一个简单的应用程序,带有一些普通视图和 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有尝试在 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.