O'Reilly logo

Programming Android by Zigurd Mednieks, G. Blake Meike, Masumi Nakamura, Laird Dornin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Static Application Resources and Context

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 Context class. Both Activity and Service extend the Context class, which means that all activities and services have access to Context data through the this pointer. In subsequent sections, we will describe how to use a Context object to access application resources at runtime.

Application Manifests

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required