Libgdx now supports Daydream mode on Android

Thanks to contributor talklittle, you can now write Daydream apps with libgdx. Daydream apps are a new feature in Android 4.2. When idle or docked, a 4.2 device can display information like a photo album and so on.

Daydreams are pretty easy to create. Here’s the one from our test collection:

Extend from AndroidDaydream, then override the onAttachedToWindow method where you create your ApplicationListener and register it via the initialize method. Note that you have to call the super onAttachedToWindow method, just as you have to call onCreate() for a normal AndroidApplication.

You can have a separate standard Android activity that lets a user define specific settings. If you do that you also need to add an xml file in your Android project’s res/xml/ folder. Here’s an example daydream.xml:

In addition to the AndroidDaydream and the settings activity, you have to register a specific service so your daydream is available to the user. Here’s an example snippet from the AndroidManifest.xml file:

And that’s it.

Libgdx Maven Support

Today i kinda finalized our Maven support. You can read all about it on this fine wiki page.

The Maven support includes:

  • An archetype that will setup the core, desktop, Android and HTML5 projects
  • Ways to package your application for the desktop, Android and HTML5
  • Ways to run your application from the command line for the desktop and Android
  • IDE integration with Eclipse and Intellij Idea. The latter is a bit untested, doing so as you read this.

This was quite a bit of an effort. We lifted a lot of work from Michael Bayne’s PlayN archetype, Team Gemserk (arielsan and ruben) helped with writting a libgdx mavenizer that takes a distribution zip and creates artifacts/poms from it. They also wrote the fine maven natives plugin and hacked m2e-android to support relative asset paths.

This is all experimental at the moment. We are waiting on the m2e-android project to merge in a pull request and publish their plugin to the Eclipse market. For now you’ll have to compile and install this plugin from Gemserk’s fork. The archetype also needs to be installed manually from source.

I hope we can publish the artifacts and the archetype to Sonatype as soon as Ruben is back from his vaccation. Then you can easily create your projects without having to manually compile anything.

The iOS backend is currently not support. I first want to fix up the gdx-setup-ui before diving into this.

And because i had so much pain while creating this with the help of all the other folks, here’s a rant for you. I’m used to Maven and use it quite heavily at work. It works brilliantly there, but there’s a difference between that environment and what we do with libgdx. At work, we run in desktop environments only. This works with any IDE easily. For libgdx, we have to deal with a ton of IDE specific issues due to the different plugins for Android/GWT, e.g. Eclipse not being able to cope with relative paths (what a bunch of bullshit). Most of the work on Maven was figuring out how to work around all those Maven/IDE specific limitations. I gave up on Netbeans, so if someone can figure out how to get the archetype working there, send me a pull request. Intellij Idea and Eclipse should work. The state of Maven, IDE plugins and Android/GWT is a horrible one, and i would not recommend anyone working on that who wants to keep his sanity. I’m not looking forward to make all this work with the upcoming Groovy based Android build system :/