1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.app; 18 19 import android.content.ComponentCallbacks; 20 import android.content.Context; 21 import android.content.ContextWrapper; 22 import android.content.res.Configuration; 23 24 /** 25 * Base class for those who need to maintain global application state. You can 26 * provide your own implementation by specifying its name in your 27 * AndroidManifest.xml's <application> tag, which will cause that class 28 * to be instantiated for you when the process for your application/package is 29 * created. 30 */ 31 public class Application extends ContextWrapper implements ComponentCallbacks { 32 33 public Application() { 34 super(null); 35 } 36 37 /** 38 * Called when the application is starting, before any other application 39 * objects have been created. Implementations should be as quick as 40 * possible (for example using lazy initialization of state) since the time 41 * spent in this function directly impacts the performance of starting the 42 * first activity, service, or receiver in a process. 43 * If you override this method, be sure to call super.onCreate(). 44 */ 45 public void onCreate() { 46 } 47 48 /** 49 * Called when the application is stopping. There are no more application 50 * objects running and the process will exit. <em>Note: never depend on 51 * this method being called; in many cases an unneeded application process 52 * will simply be killed by the kernel without executing any application 53 * code.</em> 54 * If you override this method, be sure to call super.onTerminate(). 55 */ 56 public void onTerminate() { 57 } 58 59 public void onConfigurationChanged(Configuration newConfig) { 60 } 61 62 public void onLowMemory() { 63 } 64 65 // ------------------ Internal API ------------------ 66 67 /** 68 * @hide 69 */ 70 /* package */ final void attach(Context context) { 71 attachBaseContext(context); 72 } 73 74 } 75