android.app
Class Application
java.lang.Object
android.content.Context
android.content.ContextWrapper
android.app.Application
- All Implemented Interfaces:
- ComponentCallbacks
- Direct Known Subclasses:
- MockApplication
public class Application
- extends ContextWrapper
- implements ComponentCallbacks
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.
| Fields inherited from class android.content.Context |
ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BLUETOOTH_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MODE_APPEND, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NOTIFICATION_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STATUS_BAR_SERVICE, TELEPHONY_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_SERVICE, WINDOW_SERVICE |
|
Method Summary |
(package private) void |
attach(Context context)
|
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. |
| Methods inherited from class android.content.ContextWrapper |
attachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getFilesDir, getFileStreamPath, getMainLooper, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, openFileInput, openFileOutput, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, setTheme, setWallpaper, setWallpaper, startActivity, startInstrumentation, startService, stopService, unbindService, unregisterReceiver |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Application
public Application()
onCreate
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().
onTerminate
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().
onConfigurationChanged
public void onConfigurationChanged(Configuration newConfig)
- Description copied from interface:
ComponentCallbacks
- 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.
- Specified by:
onConfigurationChanged in interface ComponentCallbacks
- Parameters:
newConfig - The new device configuration.
onLowMemory
public void onLowMemory()
- Description copied from interface:
ComponentCallbacks
- 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.
- Specified by:
onLowMemory in interface ComponentCallbacks
attach
final void attach(Context context)
Please submit a feedback, bug or feature