Top Banner
ANDROID MANIFEST
14

Android Bootcamp Tanzania: android manifest

May 14, 2015

Download

Education

Denis Minja

The Content helps those who wish to program mobile applications using android platform. The content has been used to conduct mobile application boot camps using android platform on different regions in Tanzania
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Android Bootcamp Tanzania: android manifest

ANDROID MANIFEST

Page 2: Android Bootcamp Tanzania: android manifest

Android Manifest xml File Every application must have an Android

Manifest.xml file

(with precisely that name) in its root directory.

The manifest presents essential information about the application to the Android system.

information the system must have before it can run any of the application's code.

Page 3: Android Bootcamp Tanzania: android manifest

Android Manifest xml File

Page 4: Android Bootcamp Tanzania: android manifest

Android Manifest xml File <action> <activity> <activity-alias> <application> <category> <data> <grant-uri-

permission> <instrumentation> <intent-filter> <manifest>

<meta-data> <permission> <permission-group> <permission-tree> <provider> <receiver> <service> <uses-configuration> <uses-library> <uses-permission> <uses-sdk>

Page 5: Android Bootcamp Tanzania: android manifest

5

AndroidManifest.xml

Applications should declare everything needed on the the AndroidManifest.xml file …

One AndroidManifest.xml for application ..

What's contained in it? Permissions Hw and Sw resources used by the

Application Activities Intent-filters

Page 6: Android Bootcamp Tanzania: android manifest

Android Manifest xml File The manifest is made up of a root

manifest tag with a package attribute set to the project’s package.

It usually includes an xmlns: android attribute that supplies several system attributes used within the file.

The manifest tag includes nodes that define the application components, security settings, and test classes that make up your application.

Page 7: Android Bootcamp Tanzania: android manifest

7

Activities and AndroidManifest.xml

An Android application can be composed of multiple Activities …

Each activity should be declared in the file: AndroidManifest.xml

Add a child element of <application>:

<application><activity android:name=".MyActivity" /><activity android:name=”.SecondActivity" />

</application>

Page 8: Android Bootcamp Tanzania: android manifest

8

AndroidManifest.xml example

<?xml version="1.0" encoding="utf-8"?><manifest>

<application android:icon="@drawable/icon.png" >

<activity android:name="com.example.project.MyActivity"android:label="@string/label">

</activity>

</application>

</manifest>

Page 9: Android Bootcamp Tanzania: android manifest

Android Manifest xml File

Available manifest node tags, and an XML snippet demonstrating how each one is used:

Application: A manifest can contain only one application node.

It uses attributes to specify the metadata for your application (including its title, icon, and theme).

It also acts as a container that includes the Activity, Service, Content Provider, and Broadcast Receiver tags used to specify the application components.

Page 10: Android Bootcamp Tanzania: android manifest

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloandroid" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloAndroid" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>

Page 11: Android Bootcamp Tanzania: android manifest

<manifest>

The manifest tag has the following attributes: xmlns ; the name of the namespace (android) and

where the DTD for the xml parser is located.

package ; the name of the java package for this application (must have at least two levels).

android:version ; the version code for this version of the app.

android:versionName ; The version name (for publishing)

Page 12: Android Bootcamp Tanzania: android manifest

<activity>

Child tag of <manifest> Need one <activity> tag for each activity of

the application

Attributes: android:name; the name of the activity, this will

be used as the name of the Java file and the resulting class.

android:label; a string that we will be able to programmatically retrieve the activity name at run time.

Page 13: Android Bootcamp Tanzania: android manifest

<intent-filter>

Child tag of <activity> First, what’s an intent? In OO-speak an intent is a

message sent from one program to another (message dispatcher) to tell the system what to do next.

Typically an intent consists of two parts; an action and the data that that action is supposed to use to do it.

When you select an icon on the main page the intent is to run the app associated with that icon.

The tag is used to construct an android.content.IntentFilter object to handle a particular android.content.Intent

Page 14: Android Bootcamp Tanzania: android manifest

Launcher

When you create a new application using the Android SDK tools.

The stub activity that's created for you automatically includes an intent filter that declares the activity responds to the "main" action.

It should be placed in the "launcher" category.