Search code examples
javaandroidevents

custom android.app.Application not firing onCreate event


I'm deriving a custom application from android.app.Application and I can't get its onCreate event being fired. Here's the implementation

import android.app.Application;

public class MyApplication extends Application {

    public MyApplication() {
        super();
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }
}

And here's how I'm using it:

MyApplication ctrl = new MyApplication();

Solution

  • Add following in your AndroidManifest.xml

    <application
        android:name="MyApplication"
        android:debuggable="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name">
    </application>
    

    then your onCreate() will get fired.