libgdx 中的 ApplicationListener 中未调用暂停和 dispose()
当我在 AndroidApplication 的 onDestroy()
方法中调用 exit()
方法时,pause()
和 dispose() 未被调用。谁能帮我解决这个问题。
when I am calling exit()
method in onDestroy()
method of AndroidApplication, the pause()
and dispose()
of ApplicationListener were not getting called. Can anyone help me on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
已解决。在从 AndroidApplication 调用侦听器并从中恢复时,我曾经引发一个 Activity,导致引发的 Activity 保持暂停状态。据我们所知,暂停不能立即销毁。所以 dispose() 没有被正确调用。我没有提高activity,而是使用了对话框,那么就有可能杀死android应用程序。
Got Resolved. While calling the listener from AndroidApplication and reverting back from it, I used to raise an Activity resulting that raised Activity was kept in pause. As of we know that paused can't be destroyed immediately. So dispose() was not called properly. Instead of raising activity, I used dialogue box, then there is a possibility of killing android application.
对于任何在游戏屏幕上遇到类似问题的人:
例如(我只会为该问题编写必要的代码,而不是所有应该存在的代码):
我们有 Main 类,我们将其用作所有其他屏幕的父级。
所以我们有 gameScreen 正在运行,但它的暂停()和处置()将不起作用。那是因为 gameClass“实际上是”主类(只是为了更容易描述)。将调用的pause() 和dispose() 方法是Main 方法。因此父级(Main)的方法将覆盖 gameScreen 的方法。
希望它可以帮助某人
For anyone who has similar problem with game screens:
example (i will wrote just necesary code for the problem not all which should be there):
We have Main class which we use as parent to all other screens.
So we have gameScreen running but its pause() and dispose() won't be working. That is becouse gameClass "is actually" Main class (just for easier describing). The pause() and dispose() methods that will be called are Main ones. So methods from parent (Main) will override gameScreen ones.
Hope it helps someone