application android code example

Example: android application

import android.app.Application;

public class MyApplication extends Application {
    // Called when the application is starting;
    // before any activity, service, or receiver objects have been created.
	@Override
	public void onCreate() {
	    super.onCreate();
        // your code here
	}
}

in the AndroidManifest.xml:

<application 
    android:name=".MyApplication"
    ...>

get application object in other parts of the code:

MyApplication app = (MyApplication) getApplication();

Tags:

Java Example