Skip to content

Latest commit

 

History

History
84 lines (51 loc) · 4.46 KB

4_Anatomy_Manifest.md

File metadata and controls

84 lines (51 loc) · 4.46 KB

Anatomy of the Android Manifest

Pre-work

Please read about Application Fundamentals.

Objective

Students will understand the Android Manifest file and be able to use explicit and implicit intents to control activity flow.

Do Now

Coding Bat - Words Without

Lesson

XML

Intro to XML

W3 Schools XML Tutoial

A Really, Really Good Introduction to XML

The Manifest

The Android Manifest file gives information about your project to the Android system. Let's go through each piece of this file to figure out what's going on.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.amyquispe.myapplication" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            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>

<?xml version="1.0" encoding="utf-8"?>: The version of XML being used is 1.0, and the character encoding is UTF-8.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.amyquispe.myapplication" >: Opening tag for the manifest file. xmlns stands for XML namespace. This defines the Android namespace. The package name is a unique name for the Java package your application uses. This name defines your application and cannot be changed once your app is shipped to the playstore. See also: Manifest Element.

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >: Allows the application to be participate in backup, sets the icon to an image in the resources, sets displayed app name to a string in the resources, and sets a theme for the application. See also: Application Element.

<activity android:name=".MainActivity" android:label="@string/app_name" >: Defines an activity with its classname and the user-facing name for this Activity. See also: Activity Element.

<intent-filter>: Specifies what actions the activity can respond to. See also: Intent Filter Element.

<action android:name="android.intent.action.MAIN" />: Makes the MainActivity class the main entry point for the application.

<category android:name="android.intent.category.LAUNCHER" />: Makes this Activity appear in the launcher as a top-level application.

The manifest file is also used to specify permissions that the app needs to run.

Intents and Intent Filters

Explicit Intents

Exercise: Create an Android Project with multiple activities that communicate with each other using explicit intents and handles results.

Implicit Intents

Exercise: Create an Android Project that sends an email using implicit intents.

Assessment

Support Materials

Textbook: Introducing Gradle and the Manifest (skip over the Gradle sections and go straight to The Rest of the Manifest), Tutorial #8 - Setting Up An Activity, and Intents, Intent Filters. Udacity Videos: Intents Framework, Intents as Envelopes, Launching Implicit Intents, Broadcast Intents, Intent Filters