AndroidApplicationConfiguration for libgdx

It’s been a while since i tinkered with Application configurations for the various backends. Up until now everything was expressed in the constructor/initialize methods, which has a bad impact on API changes. Today i reworked the initialization of AndroidApplication. You now have four methods:

As you can see, not a lot has changed. For both types of initialization you have a shortcut method taking an additional boolean, and a more elaborate one taking an AndroidApplicationInstance. So, what’s in that class?

Any settings we exposed previously are in there. Additionally i added support for wakelocks and disabling the accelerometer and compass to save battery. This class might be extended in the future by simply adding new fields, so the API does not break anymore.

To use this you simply create an instance, set the fields for which the defaults are not fitting for your app and pass it to one of the AndroidApplication.initialize() methods in your onCreate() method.

This will disable the sensor listeners for the accelerometer and compass and use a WakeLock to keep the screen on. You will have to add a to your manifest file if you use a wake lock.

Similar changes are upcoming for LwjglApplication, LwjglCanvas and JoglApplication. These changes will mostly be concerned with how the window is managed, full-screen support and so on. I already added stubs for all things full-screen to the Graphics interface:

This will make libgdx more desktop friendly as well and allow you to query and change the display mode on the desktop. On Android this is of course not supported as we have a fixed display mode there. I’ll probably also add a setVsync(boolean enabled) method to the Graphics interface.

Once these changes are implemented i can get back to the 3D stuff so we can release 1.0 in the near future.

Exciting stuf ahead 🙂

One thought on “AndroidApplicationConfiguration for libgdx

  1. Eclipse complains about a small typo in java code you posted:

    Instead of …

    config.useWakeLock = true;

    …it must be:

    config.useWakelock = true;

    And for sake of harmonisation

    … in Javadoc as well:
    /** whether to use a {@link WakeLock} or not.

    …and in descriptive blog too:
    Additionally i added support for wakelocks and

    This will disable the sensor listeners for the accelerometer and compass and use a WakeLock to keep

    You will have to add a to your manifest file if you use a wake lock.

Leave a Reply

Your email address will not be published.