Ch 4: Android Manifest Flashcards
Android Manifest:
Basic Overview
- Included in every Android project, in the file AndroidManifest.xml
- Defines:
- Application structure
- Metadata
- Components
- Requirements
Android Manifest:
File Structure
- Starts with a root <manifest></manifest> tag, with important attributes:
- “package” - the project’s unique package name
- “xmlns:android” - declares reference that supplies several system attibutes
-
<application></application> node:
- specifies application metadata, such as icon and theme, as attributes
- The <application></application> node contains nodes that describe each of the different components of the application:
- Activities - <activity></activity>
- Services - <service></service>
- Content Providers - <provider></provider>
- Broadcast Receivers - <receiver></receiver>
- Plus many more
Android Manifest file:
Top level Subnodes
- application
- Required, and only one
- uses-feature
- supports-screens
- supports-gl-texture
- uses-permission
- permission
Android Manifest:
Important Sub-Nodes:
application
- A manifest can only contain one application node
- Uses attributes to specify the metadata for an app, including name, icon and theme
- If using a custom application class, must specify here using the android:name attribute
- Acts as a container for component sub-nodes
Android Manifest:
Important Sub-Nodes:
uses-feature
Specifies special hardware and software features that an application requires to properly function.
If a device does not include a specified feature, the app will be prevented from being installed on it.
Features vary wildly across devices, especially as more devices support Android.
Some major feature categories that can be specified include:
Audio, Bluetooth, Camera, Touchscreen
Android Manifest:
Important Sub-Nodes:
supports-screens
Limits an application’s availability to a subset of specified screen resolutions.
It is, however, considered bad practice to use this option as it limits availability significantly.
It is a better option to create alternative layouts and responsive UI designs to support a wide variety of screen resolutions and a good experience for all users.
Android Manifest:
Important Sub-Nodes:
supports-gl-texture
Declares that the app can provide texture assets that are compressed using a specified GL texture compression format.
- You must use one of these elements for each of the texture compression formats supported
- It also must be a format that Android itself supports
Android Manifest:
Important Sub-Nodes:
uses-permission
Declares the user permissions the app requires
- Each permission specified will be presented to the user, either before app is installed or while running
- Many APIs and method calls require permission to be explicitly obtained from the user
- Generally those with an associated cost or security implication
- Examples: dialing, receiving SMS, using location based services
Android Manifest:
Important Sub-Nodes:
permission
Creates permissions to restrict access to any of the app’s shared components.
If another application’s components want to use the shared component, that app must have proper permission.
- Can use existing platform permissions
- Can also define your own permissions
- Specify:
- label
- external resource containing the description explaining risks
- level of access:
- normal
- dangerous
- signature
- signatureOrSystem
Android Manifest:
application Sub-Nodes:
activity
Required for every activity within your application.
- Use the android:name attribute to indicate the Activity class name
- Must include the main launch Activity and any other Activity that may be displayed
- Each Activity node supports intent-filter tags that define the Intents that can be used to start the Activity
Android Manifest:
application Sub-Nodes:
service
Added for each Service class used in the application, similarly to the activity tag
Android Manifest:
application Sub-Nodes:
provider
Provider tags specify each of the application’s Content Providers
- Content Providers are used to manage database access and sharing
Android Manifest:
application Sub-Nodes:
receivers
Adding a receiver tag lets you register a Broadcast Receiver prior to launching the application.
Broadcast Receivers are like global event listeners.
They will execute whenever a matching Intent is broadcast by the system.
Registering them here makes the process entirely autonomous.