Android - Activity and Application

Oh, just read that you want to make an Extension.

Probably there is no way to add custom application class from extension (moreover I believe that it is bad idea to modify application class from extension).


Previous answer:

OpenFL / Lime didn’t use custom application class. You should create it by yourself.

  1. Override android template, to do it put
<template path="templates" />

inside project.xml

  1. inside templates folder create following folders: android/template/app/src/main/java/org/haxe/lime

  2. copy AndroidManifest.xml from Lime (https://github.com/openfl/lime/blob/develop/templates/android/template/app/src/main/AndroidManifest.xml) to templates/android/template/app/src/main

  3. create MainApplication.java inside templates/android/template/app/src/main/java/org/haxe/lime/

  4. Project structure should be like that:

root_of_project/
|- ...
|- templates/
|  |- android/
|     |- template/
|        |- app/
|           |- src/
|              |- main/
|                 |- java/
|                 |  |- org/
|                 |  |  |- haxe/
|                 |  |  |  |- lime/
|                 |  |  |  |  |- MainApplication.java
|                 |- AndroidManifest.xml
|- project.xml
  1. in AndroidManifest.xml find <application ...> tag, and add android:name=".MainApplication" somewhere:
<application android:name=".MainApplication" ...>
  1. open MainApplication.java, and put following inside:
package org.haxe.lime;

import android.app.Application;
import android.content.Context;
import org.acra.*;
import org.acra.annotation.*;

@ReportsCrashes(formUri = "http://www.backendofyourchoice.com/reportpath")
public class MainApplication extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        ACRA.init(this);
    }
}

P. S. I didn’t test it, but I believe that it should work.