Programming for android in Java but using NME

I really like Haxe and NME, but someday I might want to try something that it’s default templates may not be well suited for.

NME’s main activity is defined by GameActivity.java, which is cool, but in some cases you may want to specify your own activity rather than creating an NME extension. This is something that you can totally do!

Depending on how you go about it, many of the haxe and nme libraries may no longer be safe to use. If your activity extends org.haxe.nme.GameActivity, I assume everything should be fine. If it skips it entirely on its way to android.app.Activity, I’d probably write the rest of my code in Java — just in case. I’m not really sure how the compiled c++/ndk stuff works and is tied in, with the exception of some JNI calls.

Where [package_path] is the path to your package. In my case: com/gigglingcorpse/test/java.

3. Create the necessary directories.
In your src/ folder, add a java/ directory. This is where we told NME to look for java files. In the java directory, create nested directories for your package, and create a file called MyActivity.java. In my case, it looks like this: src/java/com/gigglingcorpse/test/java/MyActivity.java

If you need to make custom changes to the Android Manifest, copy AndroidManifest.xml from tools/command-line/android/template/ into your project’s directory, and add the following line to your application’s nmml file:

<template path="AndroidManifest.xml" if="android" />

As an additional note, in the template tags in your nmml file, path is the sourcePath (where your file currently is) and rename is the destinationPath (where your file will be going relative to the bin directory for your project – in our case bin/android/bin/).