pause and dispose() not getting called in ApplicationListener in libgdx

佐手、 提交于 2019-12-13 16:58:50

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/7874353/pause-and-dispose-not-getting-called-in-applicationlistener-in-libgdx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!