Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

android application class

// Create a subclass of Application
// Application.onCreate() will be invoked when the app starts

public class ExampleApplication extends android.app.Application {
  public void onCreate() {
    super.onCreate();
    Log.i("ExampleApplication", "Application Started");
  }
}

// Register the Application subclass in the manifest

<manifest 
  xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.app">

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

// Get application object in other app components:

ExampleApplication app = (ExampleApplication) getApplication();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #android #application #class
ADD COMMENT
Topic
Name
1+4 =