LibGDX Android doesnt work, how to close app in another way?

I’m trying to close template app for android (5 sec after render() method is started).
Application is closing, but activity is alive in backgroung and I can back to app if I want.
When I’m using this.dispose() without timer, right in the end of render() method it works fine – no activity to resume Application, but when gdx draw anything this issue occures.
I’ve tried put in timer: / this.dispose() / System.exit(-1) and nothing helps if render() method already working some time.

Here is the code:

public class MyGdxGame extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
MyGdxGame instance;
boolean isReadyToClose = false;

public void create () {
    instance = this;
    batch = new SpriteBatch();
    img = new Texture("badlogic.jpg");

public void render () {, 0, 0, 1);;
    batch.draw(img, 0, 0);

    if (!isReadyToClose) {

        isReadyToClose = true;

        new Timer().scheduleTask(new Timer.Task() {
            public void run() {


        }, 5);



public void dispose () {


Stack Overflow Asked by Mikhail Kiselyov on December 27, 2020

1 Answers

One Answer

You aren't supposed to exit apps on mobile platforms, is intended to be used on desktop. Exit on Android works by the user pressing the back key and your application not catching it.

Correct answer by MrStahlfelge on December 27, 2020

Add your own answers!

Related Questions

How to center a flex container but left-align flex items

7  Asked on December 22, 2021 by etienne-nol


about IComponentConnector2

0  Asked on December 22, 2021 by yushang


WooCommerce order again and custom item data for price calculation

1  Asked on December 22, 2021 by elizabeth-parodi-roman


ruby how to stop the execution after rescue

1  Asked on December 22, 2021 by jill448


LSTM predicting constant value throughout

0  Asked on December 22, 2021 by harrys


Use main scrollbar to scroll all elements in the page

1  Asked on December 22, 2021 by marsilinou-zaky


How to read file from createReadStream in Node.js?

3  Asked on December 22, 2021 by ton1


Ask a Question

Get help from others!

© 2022 All rights reserved.