From 7025d8e4b96f14a92f9bb20902732f43d1c93e7b Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 1 Nov 2010 09:49:37 -0700 Subject: Fix issue #3152415: Various confusions in docs about Application Change-Id: Ie1b480ed7a47a3eb6ffff76bef0dcd7b2b845e83 --- core/java/android/app/Application.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/java/android/app/Application.java b/core/java/android/app/Application.java index 45ce860..b9ac848 100644 --- a/core/java/android/app/Application.java +++ b/core/java/android/app/Application.java @@ -27,6 +27,14 @@ import android.content.res.Configuration; * AndroidManifest.xml's <application> tag, which will cause that class * to be instantiated for you when the process for your application/package is * created. + * + *

There is normally no need to subclass Application. In + * most situation, static singletons can provide the same functionality in a + * more modular way. If your singleton needs a global context (for example + * to register broadcast receivers), the function to retrieve it can be + * given a {@link android.content.Context} which internally uses + * {@link android.content.Context#getApplicationContext() Context.getApplicationContext()} + * when first constructing the singleton.

*/ public class Application extends ContextWrapper implements ComponentCallbacks { @@ -46,12 +54,10 @@ public class Application extends ContextWrapper implements ComponentCallbacks { } /** - * 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(). + * This method is for use in emulated process environments. It will + * never be called on a production Android device, where processes are + * removed by simply killing them; no user code (including this callback) + * is executed when doing so. */ public void onTerminate() { } -- cgit v1.1