2.6 MANIFEST FILE
Before the Android system can start an application
component, the system must know that the component exists by reading the
applications AndroidManifest.xml
file(the “manifest” file). Your application must declare all its components in
this file, which must be at the root of the application project directory.
The manifest does a number of things in addition to
declaring the applications components, such as
·
Identify any user permissions the application
requires, such as Internet access or read-access to the user’s contacts.
·
Declare the minimum API level required by the
application, based on which APIs the application uses.
·
Declare hardware and software features used or required
by the application, such as Camera, Bluetooth service or a multi touch screen.
·
API libraries the application needs to be linked
against other than the Android framework APIs, such as the Google Maps Library.
Example,
<?xml
version= "1.0" encoding="utf-8"?>
<manifest ... > <application android:icon= "@drawable/app_icon.png" ... > <activity android:name= "com.example.project.ExampleActivity" android:label= "@string/example_label" ... > </activity> ... </application> </manifest> |
In the <application> element, the
android:icon
attribute points to resources for an icon that identifies the application.
You
must declare all application components this way,
- <activity> elements for activities.
- <service> elements for services.
- <receiver> elements for broadcast receivers.
- <provider> elements for content providers.
Activities,
services, and content providers that you include in your source but do not
declare in the manifest are not visible to the system and, consequently, can
never run. However, broadcast receivers can be either declared in the manifest
or created dynamically in code (as BroadcastReceiver
objects) and registered with the system by calling registerReceiver().
No comments:
Post a Comment