This digest is from Google's Android website translation, if there is wrong place, please the Great God Guidance
Website: http://developer.android.com/reference/android/app/Application.html
Application,activity,service,content provider are all system components of the Android framework, and when the Android program starts, a Application object is created to store some information about the system.
Launching an Android application is tantamount to starting a process where a process has only one Application object
Well, before Activity,service,broadcast,content provider, it was application.
So application belongs to a singleton pattern.
Sometimes we need to do some initialization on the custom application.
<span style= "FONT-SIZE:14PX;" >public class MyApplication extends application{ private static final String URL = "Http://api.demo.com/login"; C1/>private String value; @Override public void OnCreate () { super.oncreate (); SetValue (VALUE); Initialize global variable } public void SetValue (String value) { this.value = value; } Public String GetValue () { return value; }} </span>
We can set and get this URL in activity,service,broadcast,content provider.
Of course there are nine other methods of this class that we can rewrite.
onCreate () called when application is created
onlowmemory () The memory consumed by the application process is eliminated when the entire system is low on memory
registeractivitylifecyclecallbacks ( application.activitylifecyclecallbacks callback)
Register activity lifecycle callback
registercomponentcallbacks ( componentcallbacks callback)
Register component callbacks
registeronprovideassistdatalistener ( application.onprovideassistdatalistener callback)
Registration data persistence is called, that is, the commonly said cache
unregisteractivitylifecyclecallbacks ( application.activitylifecyclecallbacks callback)
Unregister the activity lifecycle callback
unregistercomponentcallbacks ( componentcallbacks callback)
Unregister component callbacks
unregisteronprovideassistdatalistener ( application.onprovideassistdatalistener callback)
Unregister data Persistence
Android Development-Application class