android bootcamp tanzania: android manifest
DESCRIPTION
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 TanzaniaTRANSCRIPT
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.
Android Manifest xml File
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>
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
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.
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>
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>
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.
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>
<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)
<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.
<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
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.
Adding the Library Jar File and Importing" href="https://vdocuments.us/mpl-developer-guide-android-os-paypal-history-androidnameandroidpermissionreadphonestate.html">MPL Developer Guide - Android OS - PayPal · Revision History ... android:name="android.permission.READ_PHONE_STATE" /> Adding the Library Jar File and Importing