public class

Application

extends ContextWrapper
implements ComponentCallbacks
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Application
Known Direct Subclasses

Class Overview

Base class for those who need to maintain global application state. You can provide your own implementation by specifying its name in your AndroidManifest.xml's <application> tag, which will cause that class to be instantiated for you when the process for your application/package is created.

Summary

[Expand]
Inherited Constants
From class android.content.Context
Public Constructors
Application()
Public Methods
void onConfigurationChanged(Configuration newConfig)
Called by the system when the device configuration changes while your component is running.
void onCreate()
Called when the application is starting, before any other application objects have been created.
void onLowMemory()
This is called when the overall system is running low on memory, and would like actively running process to try to tighten their belt.
void onTerminate()
Called when the application is stopping.
[Expand]
Inherited Methods
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks

Public Constructors

public Application ()

Public Methods

public void onConfigurationChanged (Configuration newConfig)

Called by the system when the device configuration changes while your component is running. Note that, unlike activities, other components are never restarted when a configuration changes: they must always deal with the results of the change, such as by re-retrieving resources.

At the time that this function has been called, your Resources object will have been updated to return resource values matching the new configuration.

Parameters
newConfig The new device configuration.

public void onCreate ()

Called when the application is starting, before any other application objects have been created. Implementations should be as quick as possible (for example using lazy initialization of state) since the time spent in this function directly impacts the performance of starting the first activity, service, or receiver in a process. If you override this method, be sure to call super.onCreate().

public void onLowMemory ()

This is called when the overall system is running low on memory, and would like actively running process to try to tighten their belt. While the exact point at which this will be called is not defined, generally it will happen around the time all background process have been killed, that is before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

Applications that want to be nice can implement this method to release any caches or other unnecessary resources they may be holding on to. The system will perform a gc for you after returning from this method.

public void onTerminate ()

Called when the application is stopping. There are no more application objects running and the process will exit. Note: never depend on this method being called; in many cases an unneeded application process will simply be killed by the kernel without executing any application code. If you override this method, be sure to call super.onTerminate().