libgdx 中的 ApplicationListener 中未调用暂停和 dispose()

发布于 2024-12-11 20:12:12 字数 183 浏览 0 评论 0原文

当我在 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 技术交流群。

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

发布评论

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

评论(2

梦里°也失望 2024-12-18 20:12:12

已解决。在从 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.

千と千尋 2024-12-18 20:12:12

对于任何在游戏屏幕上遇到类似问题的人:

例如(我只会为该问题编写必要的代码,而不是所有应该存在的代码):

我们有 Main 类,我们将其用作所有其他屏幕的父级。

public class Main extends Game {
    public GameScreen gameScreen;
    public void create(){
        gameScreen = new GameScreen(this);
        setScreen(gameScreen);  
    }  
}

所以我们有 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.

public class Main extends Game {
    public GameScreen gameScreen;
    public void create(){
        gameScreen = new GameScreen(this);
        setScreen(gameScreen);  
    }  
}

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

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