Applications may need to store significant
amounts of data to control their runtime behavior. Some of this data
describes the application environment: the app name, the intents it
registers, the permissions it needs and so on. This data is stored in
a file called the manifest. Other data might be
images to display or simple text strings, indicating what background
color or font to use. These data are called
resources. Together, all this information forms
the context of the application, and Android
provides access to it through the
Service extend the
Context class, which means that all activities and services have access
Context data through the
this pointer. In subsequent
sections, we will describe how to use a
Context object to access application
resources at runtime.
Android requires applications to explicitly describe their contents in an XML file called AndroidManifest.xml. Here, applications declare the presence of content providers, services, required permissions, and other elements. The application context makes this data available to the Android runtime. The manifest file organizes an Android application into a well-defined structure that is shared by all applications and enables the Android operating system to load and execute them in a managed environment. The structure encompasses a common directory layout and common file types in those directories.
As we’ve seen, the four ...