Search code examples
androidlibgdx

Adding Gdx.app.exit() in AndroidLauncher


In my LibGdx based android game, I planned to use the exit statement in AndroidLauncher class instead of the core LibGdx project. It works fine

Gdx.app.exit();

Question 1. Will there be any difference if I use it in AndroidLauncher class instead of the LibGdx screen ?


Solution

  • No matter from where you call exit() method on static reference of Application class.

    It schedule an exit from the application.

    On android, this will cause a call to pause() and dispose() some time in the future.

    Keep in mind :

    • It will not immediately finish your application.
    • On iOS this should be avoided in production as it breaks Apples guidelines.