SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Android components & manifest
Ilio Catallo, Eleonora Ciceri – Politecnico di Milano
ilio.catallo@polimi.it, eleonora.ciceri@polimi.it
Principles
2
Android applications
¤ An Android application is made of different components
¤ Namely:
¤ Activities (and associated Views)
¤ Broadcast receivers
¤ Services
¤ Persistence Providers
3
Android applications
¤ An Android application is made of different components
¤ Namely:
¤ Activities (and associated Views)
¤ Broadcast receivers
¤ Services
¤ Persistence Providers
4
Principles
5
activity
application
¤ An activity is a single, focused thing that the user
can do
¤ Each activity is associated with a window in which to
draw the user interface
Principles
6
view
activity
application
¤ The view is the basic building block for user
interface components
¤ Responsible for drawing and event handling
¤ Examples: button, textbox
Principles
7
view
activity
application
activity
view
¤ Most basic applications are made of just one Activity
¤ However, typical Android apps comprise multiple
Activities
Principles
8
intent
view
activity
application
activity
view
¤ Intents are messages that are passed between
components (e.g., Activities)
¤ The most significant use of Intents is launching new
Activities
Principles
9
intent
view
activity
application
activity
view
9
view
activity
third-party
application
¤ What if a useful Activity is part of
a third-party application?
Principles
10
intent
view
activity
application
view
activity
third-party
application
activity
view intent
¤ By casting an intent, third-party
activities can be used as if they
were part of our app
Remaining components
¤ The remaining components play less intuitive roles
¤ Namely:
¤ Services implement long-running, background operations
¤ Persistence providers supply access to data managed by
the application
¤ Broadcast receivers enable applications to receive intents
that are broadcast by the system or by other applications
11
Composing the puzzle
12
Composing the puzzle
¤ Each Android application includes a manifest file
(AndroidManifest.xml), which describes
¤ each single component
¤ the interaction between different components
¤ Specifically, the manifest defines:
¤ the application metadata
¤ the application requirements
¤ the application structure and components
¤ The manifest is stored in the root of the project hierarchy
13
Manifest structure: manifest node
14
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ <manifest> is the root node of the
AndroidManifest.xmlfile
<manifest
xmlns:android=
“http://schemas.android.com/apk/res/android”
package="it.polimi.mad”
android:versionCode="1"
android:versionName="0.9 Beta"
android:installLocation="preferExternal”>
...
</manifest>
Manifest structure: manifest node
15
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ Attributes
¤ versionCode: an integer
representing the version of the
application code
¤ versionName: a string
representing the release version
of the application code, as
shown to users
¤ installLocation: the default
install location for the application
Manifest structure: uses-sdk node
16
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ <uses-sdk> lets you express an
application’s compatibility with one
or more versions of the Android
platform
¤ This tag specifies the version of the
APIs, NOT the SDK
<uses-sdk android:minSdkVersion=“8”
android:targetSdkVersion=”21” />
Manifest structure: uses-sdk node
17
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ Attributes
¤ android:minSdkVersion: an
integer designating the minimum
API Level required for the
application to run
¤ android:targetSdkVersion: an
integer designating the API Level
the application targets
Manifest structure: application node
18
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ <application> defines the
application metadata
¤ Example: icon, title
¤ It acts as a container for activities,
services, content providers and
broadcast receivers
<application android:icon="@drawable/icon”
android:name= ”.MyApp"
android:debuggable="true">
...
</application>
Manifest structure: application node
19
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ <application> defines the
application metadata
¤ Example: icon, title
¤ It acts as a container for activities,
services, content providers and
broadcast receivers
<application android:icon="@drawable/icon”
android:name= ”.MyApp"
android:debuggable="true">
...
</application>
. is used as a shorthand
for the application’s
package name
Manifest structure: application node
20
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ Attributes
¤ android:icon: reference to a
resource containing the
application icon image
¤ android:name: the fully qualified
name for the class inheriting from
Application*
* The subclass is optional. In the absence of a subclass, an
instance of the base Applicationclass is used
Manifest structure: activity node
21
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ <activity> is required for every
Activity within the application
<activity android:name=".MyActivity”
android:label="@string/activity_name">
...
</activity>
Manifest structure: activity node
¤ Attributes
¤ android:name: the name of the
class that implements the activity
(should be a fully qualified class
name)
¤ android:label: a user-readable
label for the activity, displayed
when the activity is represented
to the user (often along with the
activity icon)
22
uses-sdk
application
activity
service
provider
receiver
intent-filter
Manifest structure: intent-filter node
23
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ <intent-filter>specifies the
types of intents that an activity,
service, or broadcast receiver can
respond to
<intent-filter>
<action android:name="android.
intent.action.MAIN”/>
<category android:name="android.
intent.category.LAUNCHER”/>
</intent-filter>
Manifest structure: intent-filter node
24
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ Sub-nodes
¤ action: the name of the action
¤ category: adds a category name
to an intent filter.
¤ Some standard actions and
categories are defined in the Intent
class
¤ ACTION_MAIN: starts up as the initial
activity of a task (no data input
and no returned output)
¤ CATEGORY_LAUNCHER: the activity
must be invoked by the launcher
Manifest structure: service node
25
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ <service> declares a Service
class implementing long-running
background operations
<service android:name=".MyService">
...
</service>
Manifest structure: service node
26
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ Attributes
¤ android:name: qualifiedname
of the class implementing the
service
Manifest structure: provider node
27
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ <provider> declares a content
provider component, supplying
access to data managed by the
application
<provider android:name=".MyContentProvider"
android:authorities=“it.polimi.
mad.contentprovider"/>
Manifest structure: provider node
28
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ Attributes
¤ android:name: the fully qualified
name of the class that
implements the content provider
¤ android:authorities: a list of
one or more URIs that identify
data offered by the content
provider
¤ To avoid conflicts with
content providers in other
apps, the URIs should use a
Java-style package naming
convention
Manifest structure: receiver node
29
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ <receiver> declares a broadcast
receiver as one of the application's
components
¤ Broadcast receivers enable
applications to receive intents
that are broadcast by the system
or by other applications
<receiver android:name=".MyIntentReceiver">
<intent-filter>
<action android:name=”it.polimi.
mad.mybroadcastaction”/>
</intent-filter>
</receiver>
Manifest structure: receiver node
30
uses-sdk
application
activity
service
provider
receiver
intent-filter
¤ Attributes
¤ android:name: the fully qualified
name of the class that
implements the broadcast
receiver
TakeNotes:
AndroidManifest.xml
31
Android 5.0
(Lollipop)
Android 2.2
(Froyo)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.polimi.ma.takenotes"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="it.polimi.ma.takenotes.ToDoListActivity"
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>
TakeNotes:
AndroidManifest.xml
32
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.polimi.ma.takenotes"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="it.polimi.ma.takenotes.ToDoListActivity"
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>
One single activity,
implemented by this class
TakeNotes:
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.polimi.ma.takenotes"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="it.polimi.ma.takenotes.ToDoListActivity"
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>
33
Resource URI
(we will see in a while
what it means…)
Android application structure
¤ Programming an Android application involves:
¤ Writing the business logic code
¤ Providing the resources required for the user interface
¤ User interface definition (via XML)
¤ Icons
¤ Localized strings
¤ Providing the multimedia content (i.e., assets), which will be
used by the application
¤ Video / photo collections
34
Android Project File Structure
35
src/
build/
Source code that is auto-generated by Android Studio
libs/
Precompiled third-party libraries (JAR archives) that you
want to use in your app
assets/
Other media that you want to use in your app (e.g.,
videos, sounds)
res/
GUI layouts, icons, menus and so forth
java/
Source code that you write for your app
main/
source code and resources
app/
Create a Hello World application
36
Hello World application – Step 1
37
Specify the application name...
... and the company name (which automatically
defines the package name)
Hello World application – Step 2
38
Specify the platform on which the application will run...
... and the supported API
Hello World application – Step 3
39
Select this to create a
standard, empty activity
Hello World application – Step 4
40
Give a name to the activity (i.e., the
Java class implementing the activity)
Android Studio:
Hello World application
41
Project structure
Code
Application
preview
References
42
References
¤ Reto Meier, Professional Android 4 Application
development
3rd Ed., Wrox
43

Weitere ähnliche Inhalte

Was ist angesagt?

Android app development
Android app developmentAndroid app development
Android app developmentTanmoy Roy
 
Android resource
Android resourceAndroid resource
Android resourceKrazy Koder
 
Introduction to Mobile Development
Introduction to Mobile DevelopmentIntroduction to Mobile Development
Introduction to Mobile DevelopmentPragnesh Vaghela
 
Introduction to Android ppt
Introduction to Android pptIntroduction to Android ppt
Introduction to Android pptTaha Malampatti
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersBoom Shukla
 
Basic android-ppt
Basic android-pptBasic android-ppt
Basic android-pptSrijib Roy
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Ahsanul Karim
 
Android contentprovider
Android contentproviderAndroid contentprovider
Android contentproviderKrazy Koder
 
Introduction to Android, Architecture & Components
Introduction to  Android, Architecture & ComponentsIntroduction to  Android, Architecture & Components
Introduction to Android, Architecture & ComponentsVijay Rastogi
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android StudioSuyash Srijan
 
Android Development Slides
Android Development SlidesAndroid Development Slides
Android Development SlidesVictor Miclovich
 
Android Operating System
Android Operating SystemAndroid Operating System
Android Operating SystemBilal Mirza
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in androidPrawesh Shrestha
 

Was ist angesagt? (20)

Android app development
Android app developmentAndroid app development
Android app development
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Android studio ppt
Android studio pptAndroid studio ppt
Android studio ppt
 
Android resource
Android resourceAndroid resource
Android resource
 
Introduction to Mobile Development
Introduction to Mobile DevelopmentIntroduction to Mobile Development
Introduction to Mobile Development
 
Android User Interface
Android User InterfaceAndroid User Interface
Android User Interface
 
Introduction to Android ppt
Introduction to Android pptIntroduction to Android ppt
Introduction to Android ppt
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginners
 
Android Fragment
Android FragmentAndroid Fragment
Android Fragment
 
Basic android-ppt
Basic android-pptBasic android-ppt
Basic android-ppt
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
 
Android UI
Android UIAndroid UI
Android UI
 
Android contentprovider
Android contentproviderAndroid contentprovider
Android contentprovider
 
Introduction to Android, Architecture & Components
Introduction to  Android, Architecture & ComponentsIntroduction to  Android, Architecture & Components
Introduction to Android, Architecture & Components
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android Studio
 
Android Development Slides
Android Development SlidesAndroid Development Slides
Android Development Slides
 
Android Operating System
Android Operating SystemAndroid Operating System
Android Operating System
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Mobile Application Testing
Mobile Application TestingMobile Application Testing
Mobile Application Testing
 

Andere mochten auch

Events and Listeners in Android
Events and Listeners in AndroidEvents and Listeners in Android
Events and Listeners in Androidma-polimi
 
Open Intents - Android Intents Mechanism and Dependency Management
Open Intents - Android Intents Mechanism and Dependency ManagementOpen Intents - Android Intents Mechanism and Dependency Management
Open Intents - Android Intents Mechanism and Dependency ManagementFriedger Müffke
 
Broadcast Receivers in Android
Broadcast Receivers in AndroidBroadcast Receivers in Android
Broadcast Receivers in Androidma-polimi
 
Android Application Fundamentals
Android Application FundamentalsAndroid Application Fundamentals
Android Application FundamentalsVikalp Jain
 
BroadcastReceivers in Android
BroadcastReceivers in AndroidBroadcastReceivers in Android
BroadcastReceivers in AndroidPerfect APK
 
Android life cycle
Android life cycleAndroid life cycle
Android life cycle瑋琮 林
 
Intents in Android
Intents in AndroidIntents in Android
Intents in Androidma-polimi
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
 
Building Mobile Application Using PhoneGap
Building Mobile Application Using PhoneGapBuilding Mobile Application Using PhoneGap
Building Mobile Application Using PhoneGapRajashekar Bhagavatula
 
Mobile payment i phone application
Mobile payment i phone applicationMobile payment i phone application
Mobile payment i phone applicationcaneren
 
Mobile phone applications
Mobile phone applicationsMobile phone applications
Mobile phone applicationsNazish khalid
 
Barrett School Store Mobile Phone Application Proposal
Barrett School Store Mobile Phone Application ProposalBarrett School Store Mobile Phone Application Proposal
Barrett School Store Mobile Phone Application ProposalFabeeha Ahmed
 
Loyalty & Rewards Points Application on your mobile phone, iPhone, Android
Loyalty & Rewards Points Application on your mobile phone, iPhone, AndroidLoyalty & Rewards Points Application on your mobile phone, iPhone, Android
Loyalty & Rewards Points Application on your mobile phone, iPhone, AndroidMike Taylor
 
Introduction To Mobile Application Development
Introduction  To  Mobile Application DevelopmentIntroduction  To  Mobile Application Development
Introduction To Mobile Application DevelopmentSteven James
 
Basic android development
Basic android developmentBasic android development
Basic android developmentUpanya Singh
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycleSoham Patel
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAhsanul Karim
 

Andere mochten auch (20)

Events and Listeners in Android
Events and Listeners in AndroidEvents and Listeners in Android
Events and Listeners in Android
 
School updated
School updatedSchool updated
School updated
 
Open Intents - Android Intents Mechanism and Dependency Management
Open Intents - Android Intents Mechanism and Dependency ManagementOpen Intents - Android Intents Mechanism and Dependency Management
Open Intents - Android Intents Mechanism and Dependency Management
 
Broadcast Receivers in Android
Broadcast Receivers in AndroidBroadcast Receivers in Android
Broadcast Receivers in Android
 
Logcatの話
Logcatの話Logcatの話
Logcatの話
 
Android Application Fundamentals
Android Application FundamentalsAndroid Application Fundamentals
Android Application Fundamentals
 
Android Fundamentals
Android FundamentalsAndroid Fundamentals
Android Fundamentals
 
BroadcastReceivers in Android
BroadcastReceivers in AndroidBroadcastReceivers in Android
BroadcastReceivers in Android
 
Android life cycle
Android life cycleAndroid life cycle
Android life cycle
 
Intents in Android
Intents in AndroidIntents in Android
Intents in Android
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
Building Mobile Application Using PhoneGap
Building Mobile Application Using PhoneGapBuilding Mobile Application Using PhoneGap
Building Mobile Application Using PhoneGap
 
Mobile payment i phone application
Mobile payment i phone applicationMobile payment i phone application
Mobile payment i phone application
 
Mobile phone applications
Mobile phone applicationsMobile phone applications
Mobile phone applications
 
Barrett School Store Mobile Phone Application Proposal
Barrett School Store Mobile Phone Application ProposalBarrett School Store Mobile Phone Application Proposal
Barrett School Store Mobile Phone Application Proposal
 
Loyalty & Rewards Points Application on your mobile phone, iPhone, Android
Loyalty & Rewards Points Application on your mobile phone, iPhone, AndroidLoyalty & Rewards Points Application on your mobile phone, iPhone, Android
Loyalty & Rewards Points Application on your mobile phone, iPhone, Android
 
Introduction To Mobile Application Development
Introduction  To  Mobile Application DevelopmentIntroduction  To  Mobile Application Development
Introduction To Mobile Application Development
 
Basic android development
Basic android developmentBasic android development
Basic android development
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
 

Ähnlich wie Android Components & Manifest

Hello android world
Hello android worldHello android world
Hello android worldeleksdev
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureVijay Rastogi
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
Android应用开发简介
Android应用开发简介Android应用开发简介
Android应用开发简介easychen
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principlesHenk Laracker
 
Mobile application development
Mobile application developmentMobile application development
Mobile application developmentumesh patil
 
Android application development
Android application developmentAndroid application development
Android application developmentMd. Mujahid Islam
 
Data Transfer between activities and Database
Data Transfer between activities and Database Data Transfer between activities and Database
Data Transfer between activities and Database faiz324545
 
Android broadcast receiver tutorial
Android broadcast receiver  tutorialAndroid broadcast receiver  tutorial
Android broadcast receiver tutorialmaamir farooq
 
Android broadcast receiver tutorial
Android broadcast receiver   tutorialAndroid broadcast receiver   tutorial
Android broadcast receiver tutorialmaamir farooq
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development BasicMonir Zzaman
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycleKumar
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answerskavinilavuG
 
Android studio
Android studioAndroid studio
Android studioAndri Yabu
 

Ähnlich wie Android Components & Manifest (20)

Hello android world
Hello android worldHello android world
Hello android world
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Android应用开发简介
Android应用开发简介Android应用开发简介
Android应用开发简介
 
Best android classes in mumbai
Best android classes in mumbaiBest android classes in mumbai
Best android classes in mumbai
 
Unit2
Unit2Unit2
Unit2
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principles
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Mobile application development
Mobile application developmentMobile application development
Mobile application development
 
Android101
Android101Android101
Android101
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android session 2
Android session 2Android session 2
Android session 2
 
Data Transfer between activities and Database
Data Transfer between activities and Database Data Transfer between activities and Database
Data Transfer between activities and Database
 
Android broadcast receiver tutorial
Android broadcast receiver  tutorialAndroid broadcast receiver  tutorial
Android broadcast receiver tutorial
 
Android broadcast receiver tutorial
Android broadcast receiver   tutorialAndroid broadcast receiver   tutorial
Android broadcast receiver tutorial
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development Basic
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answers
 
Android studio
Android studioAndroid studio
Android studio
 

Kürzlich hochgeladen

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 

Kürzlich hochgeladen (20)

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

Android Components & Manifest

  • 1. Android components & manifest Ilio Catallo, Eleonora Ciceri – Politecnico di Milano ilio.catallo@polimi.it, eleonora.ciceri@polimi.it
  • 3. Android applications ¤ An Android application is made of different components ¤ Namely: ¤ Activities (and associated Views) ¤ Broadcast receivers ¤ Services ¤ Persistence Providers 3
  • 4. Android applications ¤ An Android application is made of different components ¤ Namely: ¤ Activities (and associated Views) ¤ Broadcast receivers ¤ Services ¤ Persistence Providers 4
  • 5. Principles 5 activity application ¤ An activity is a single, focused thing that the user can do ¤ Each activity is associated with a window in which to draw the user interface
  • 6. Principles 6 view activity application ¤ The view is the basic building block for user interface components ¤ Responsible for drawing and event handling ¤ Examples: button, textbox
  • 7. Principles 7 view activity application activity view ¤ Most basic applications are made of just one Activity ¤ However, typical Android apps comprise multiple Activities
  • 8. Principles 8 intent view activity application activity view ¤ Intents are messages that are passed between components (e.g., Activities) ¤ The most significant use of Intents is launching new Activities
  • 10. Principles 10 intent view activity application view activity third-party application activity view intent ¤ By casting an intent, third-party activities can be used as if they were part of our app
  • 11. Remaining components ¤ The remaining components play less intuitive roles ¤ Namely: ¤ Services implement long-running, background operations ¤ Persistence providers supply access to data managed by the application ¤ Broadcast receivers enable applications to receive intents that are broadcast by the system or by other applications 11
  • 13. Composing the puzzle ¤ Each Android application includes a manifest file (AndroidManifest.xml), which describes ¤ each single component ¤ the interaction between different components ¤ Specifically, the manifest defines: ¤ the application metadata ¤ the application requirements ¤ the application structure and components ¤ The manifest is stored in the root of the project hierarchy 13
  • 14. Manifest structure: manifest node 14 uses-sdk application activity service provider receiver intent-filter ¤ <manifest> is the root node of the AndroidManifest.xmlfile <manifest xmlns:android= “http://schemas.android.com/apk/res/android” package="it.polimi.mad” android:versionCode="1" android:versionName="0.9 Beta" android:installLocation="preferExternal”> ... </manifest>
  • 15. Manifest structure: manifest node 15 uses-sdk application activity service provider receiver intent-filter ¤ Attributes ¤ versionCode: an integer representing the version of the application code ¤ versionName: a string representing the release version of the application code, as shown to users ¤ installLocation: the default install location for the application
  • 16. Manifest structure: uses-sdk node 16 uses-sdk application activity service provider receiver intent-filter ¤ <uses-sdk> lets you express an application’s compatibility with one or more versions of the Android platform ¤ This tag specifies the version of the APIs, NOT the SDK <uses-sdk android:minSdkVersion=“8” android:targetSdkVersion=”21” />
  • 17. Manifest structure: uses-sdk node 17 uses-sdk application activity service provider receiver intent-filter ¤ Attributes ¤ android:minSdkVersion: an integer designating the minimum API Level required for the application to run ¤ android:targetSdkVersion: an integer designating the API Level the application targets
  • 18. Manifest structure: application node 18 uses-sdk application activity service provider receiver intent-filter ¤ <application> defines the application metadata ¤ Example: icon, title ¤ It acts as a container for activities, services, content providers and broadcast receivers <application android:icon="@drawable/icon” android:name= ”.MyApp" android:debuggable="true"> ... </application>
  • 19. Manifest structure: application node 19 uses-sdk application activity service provider receiver intent-filter ¤ <application> defines the application metadata ¤ Example: icon, title ¤ It acts as a container for activities, services, content providers and broadcast receivers <application android:icon="@drawable/icon” android:name= ”.MyApp" android:debuggable="true"> ... </application> . is used as a shorthand for the application’s package name
  • 20. Manifest structure: application node 20 uses-sdk application activity service provider receiver intent-filter ¤ Attributes ¤ android:icon: reference to a resource containing the application icon image ¤ android:name: the fully qualified name for the class inheriting from Application* * The subclass is optional. In the absence of a subclass, an instance of the base Applicationclass is used
  • 21. Manifest structure: activity node 21 uses-sdk application activity service provider receiver intent-filter ¤ <activity> is required for every Activity within the application <activity android:name=".MyActivity” android:label="@string/activity_name"> ... </activity>
  • 22. Manifest structure: activity node ¤ Attributes ¤ android:name: the name of the class that implements the activity (should be a fully qualified class name) ¤ android:label: a user-readable label for the activity, displayed when the activity is represented to the user (often along with the activity icon) 22 uses-sdk application activity service provider receiver intent-filter
  • 23. Manifest structure: intent-filter node 23 uses-sdk application activity service provider receiver intent-filter ¤ <intent-filter>specifies the types of intents that an activity, service, or broadcast receiver can respond to <intent-filter> <action android:name="android. intent.action.MAIN”/> <category android:name="android. intent.category.LAUNCHER”/> </intent-filter>
  • 24. Manifest structure: intent-filter node 24 uses-sdk application activity service provider receiver intent-filter ¤ Sub-nodes ¤ action: the name of the action ¤ category: adds a category name to an intent filter. ¤ Some standard actions and categories are defined in the Intent class ¤ ACTION_MAIN: starts up as the initial activity of a task (no data input and no returned output) ¤ CATEGORY_LAUNCHER: the activity must be invoked by the launcher
  • 25. Manifest structure: service node 25 uses-sdk application activity service provider receiver intent-filter ¤ <service> declares a Service class implementing long-running background operations <service android:name=".MyService"> ... </service>
  • 26. Manifest structure: service node 26 uses-sdk application activity service provider receiver intent-filter ¤ Attributes ¤ android:name: qualifiedname of the class implementing the service
  • 27. Manifest structure: provider node 27 uses-sdk application activity service provider receiver intent-filter ¤ <provider> declares a content provider component, supplying access to data managed by the application <provider android:name=".MyContentProvider" android:authorities=“it.polimi. mad.contentprovider"/>
  • 28. Manifest structure: provider node 28 uses-sdk application activity service provider receiver intent-filter ¤ Attributes ¤ android:name: the fully qualified name of the class that implements the content provider ¤ android:authorities: a list of one or more URIs that identify data offered by the content provider ¤ To avoid conflicts with content providers in other apps, the URIs should use a Java-style package naming convention
  • 29. Manifest structure: receiver node 29 uses-sdk application activity service provider receiver intent-filter ¤ <receiver> declares a broadcast receiver as one of the application's components ¤ Broadcast receivers enable applications to receive intents that are broadcast by the system or by other applications <receiver android:name=".MyIntentReceiver"> <intent-filter> <action android:name=”it.polimi. mad.mybroadcastaction”/> </intent-filter> </receiver>
  • 30. Manifest structure: receiver node 30 uses-sdk application activity service provider receiver intent-filter ¤ Attributes ¤ android:name: the fully qualified name of the class that implements the broadcast receiver
  • 31. TakeNotes: AndroidManifest.xml 31 Android 5.0 (Lollipop) Android 2.2 (Froyo) <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.polimi.ma.takenotes" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name="it.polimi.ma.takenotes.ToDoListActivity" 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>
  • 32. TakeNotes: AndroidManifest.xml 32 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.polimi.ma.takenotes" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name="it.polimi.ma.takenotes.ToDoListActivity" 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> One single activity, implemented by this class
  • 33. TakeNotes: AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.polimi.ma.takenotes" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name="it.polimi.ma.takenotes.ToDoListActivity" 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> 33 Resource URI (we will see in a while what it means…)
  • 34. Android application structure ¤ Programming an Android application involves: ¤ Writing the business logic code ¤ Providing the resources required for the user interface ¤ User interface definition (via XML) ¤ Icons ¤ Localized strings ¤ Providing the multimedia content (i.e., assets), which will be used by the application ¤ Video / photo collections 34
  • 35. Android Project File Structure 35 src/ build/ Source code that is auto-generated by Android Studio libs/ Precompiled third-party libraries (JAR archives) that you want to use in your app assets/ Other media that you want to use in your app (e.g., videos, sounds) res/ GUI layouts, icons, menus and so forth java/ Source code that you write for your app main/ source code and resources app/
  • 36. Create a Hello World application 36
  • 37. Hello World application – Step 1 37 Specify the application name... ... and the company name (which automatically defines the package name)
  • 38. Hello World application – Step 2 38 Specify the platform on which the application will run... ... and the supported API
  • 39. Hello World application – Step 3 39 Select this to create a standard, empty activity
  • 40. Hello World application – Step 4 40 Give a name to the activity (i.e., the Java class implementing the activity)
  • 41. Android Studio: Hello World application 41 Project structure Code Application preview
  • 43. References ¤ Reto Meier, Professional Android 4 Application development 3rd Ed., Wrox 43