I’ve been working on several ios/android extensions for my needs now, and I think using templates for those is a bad practice.
For instance, if you use multiple extension with template overriding the same file, you have conflict and have to make your own template, adding manual step for use.
So I try not to use template but in some case I have no choice, for instance, sometimes I have to override the AndroidManifest.xml to indicate an other application class like here : https://github.com/TBaudon/extension-parse/blob/master/templates/android/template/AndroidManifest.xml .
Why not use “onCreate” to run your extension initialisation code ? you may ask.
Well I found “onCreate” is called too late in some case (in my case with parse it needed to run from notification center).
So, would it be possible to change the way java extension are loaded so that we can add extension to a default Application.java without having to use template ? Or is there already a way that i’m not aware of ?
All the extensions use the Android “library project” system, which enables them to add their own manifest XML values and so on.
If you think we should extend the Extension.java class with additional hooks, that might be a good idea, let me know. That all works without templates (and is designed to help multiple extensions plug-in nicely )
sorry I wasn’t clear, I don’t use template to make my extension normaly, I use the default way with Android library project as you said, but, in some case, there is no choice to use a template to replace some file, as far as I know.
In an extension I needed to replace the application tag’s attribute “android:name” of the android.manifest , and it was not possible to do it with manifest merging so I needed to make a template to override android.manifest to run some initialisation code before the activity launch.
What’s bother me is , if I use an other extension wich do the same, I have to merge manifest and overrided Application.java manually.
An other hook in the Extension class , like “onApplicationLaunched” would be nice, but, as far as I know, Extension are instanciated in GameActivity so it’s already too late to trigger the callback.
android:name is used by default, and what did you need it to be?