SlideShare a Scribd company logo
Android Insights - 1


       Intents
Topics to be Covered
• Basic Components of Android
• Intents & Intent Filters
• Intent Resolution




2/8/2012           Android Insights - 1   2/10
Basic Components of Android
• Activity
      – provides a screen with which users can interact in
        order to do something
• Service
      – performs long-running operations in the background
        and does not provide a user interface
• Content Provider
      – manages access to a structured set of data
• Intent
      – an abstract description of an operation to be
        performed

2/8/2012                    Android Insights - 1             3/10
Motivation Towards Intents
• We want all the activities, services, broadcast
  receivers etc. to be loosely-coupled.
• Message Passing is the way to go.
• Intents are those messages which are used to
  communicate among the components.

Remember? “An intent is an abstract description
of an operation to be performed.”
2/8/2012             Android Insights - 1       4/10
Primary Structure of an Intent
• Action
      – The general action to be performed
• Data
      – The data to operate on, expressed as a URI.

Example of an action-data pair:
ACTION_VIEW        content://contacts/people/1
Display information about the person whose identifier
is "1".

2/8/2012                  Android Insights - 1        5/10
How Intents Work
• Given an arbitrary intent we need to know what to do
  with it.
• This is handled by the process of Intent
  resolution, which maps an Intent to an
  Activity, BroadcastReceiver, or Service (or sometimes
  two or more activities/receivers) that can handle it.
• The intent resolution mechanism basically revolves
  around matching an Intent against all of the <intent-
  filter> descriptions in the installed application
  packages.
• There is a manifest file in the next slide where activities
  are marked with the intents they can operate on.

2/8/2012                  Android Insights - 1            6/10
How Intents Work...




           What are those category and data elements in intent filters??
2/8/2012              Android Insights - 1                          7/10
The Other Parts of Intent
•   Category
      – Gives additional information about the action to execute.
      – For example, CATEGORY_LAUNCHER means it should appear in the Launcher as a top-level
        application.
•   Type
      – Specifies an explicit type (a MIME type) of the intent data.
      – Normally the type is inferred from the data itself. By setting this attribute, you disable that
        evaluation and force an explicit type.
      – For example, setting type to image/jpeg means the activity can handle only jpeg files and not
        other image files such as png, gif etc.
•   Extras
      – A Bundle of any additional information.
      – Can be used to provide extended information to the component.
      – For example, an ACTION_HEADSET_PLUG has a "state" extra indicating whether the headset is
        now plugged in or unplugged, as well as a "name" extra for the type of headset.
•   Flags
      – Flags of various sorts.
      – For example, in the case of FLAG_ACTIVITY_NO_ANIMATION, if set in an Intent passed to
        Context.startActivity(), this flag will prevent the system from applying an activity transition
        animation to go to the next activity state.

2/8/2012                                     Android Insights - 1                                         8/10
Explicit Intents
Hey, the Intent-Resolution mechanism of Android is cool, but
I just need to start a new activity – that’s all. All those fuzz
aren’t worth of merely starting an activity, I guess???
• You’re right.
• There is a last part in an intent – Component.
• An intent can have specified a component (via
   setComponent(ComponentName) or
   setClass(Context, Class)), which provides the exact class to be
   run.
• Often these will not include any other information, simply being a
   way for an application to launch various internal activities it has as
   the user interacts with the application.
• Intents having components set are called Explicit Intents in contrast
   to their counterparts Implicit Intents.
2/8/2012                       Android Insights - 1                   9/10
References
• Intent Structure and Intent Resolution
  Mechanism:
  http://developer.android.com/guide/topics/in
  tents/intents-filters.html
• Standard actions, categories, flags and extra
  data:
  http://developer.android.com/reference/andr
  oid/content/Intent.html

2/8/2012            Android Insights - 1     10/10

More Related Content

PDF
software engineering notes for cse/it fifth semester
KEY
Android Development: The Basics
PDF
An introduction to software engineering
PPT
Software Engineering ppt
PDF
Android Basic Components
PDF
Software engineering lecture notes
PPTX
Introduction To Software Engineering
PDF
Android intent
software engineering notes for cse/it fifth semester
Android Development: The Basics
An introduction to software engineering
Software Engineering ppt
Android Basic Components
Software engineering lecture notes
Introduction To Software Engineering
Android intent

Similar to Android Insights - 1 [Intents] (20)

PDF
Intents are Awesome
ODP
Ppt 2 android_basics
PPT
Android - Android Intent Types
PPT
ANDROID
DOCX
Android intents in android application-chapter7
PPTX
Intents
PPTX
learn about Android Extended Intents.pptx
ODP
Nativa Android Applications development
PDF
Android Lesson 3 - Intent
PDF
Dueling Banjos: Inter-app Communication
PDF
Ch5 intent broadcast receivers adapters and internet
PPT
Intent, Service and BroadcastReciver (2).ppt
PPTX
Android development session 2 - intent and activity
PPTX
W5_Lec09_Lec10_Intents.pptx
PPT
Lecture-3.ppt
PPT
android.ppt
PPT
Android Training - Part 2
PDF
Intents in Android
PDF
Open Intents - Android Intents Mechanism and Dependency Management
PPT
Android overview
Intents are Awesome
Ppt 2 android_basics
Android - Android Intent Types
ANDROID
Android intents in android application-chapter7
Intents
learn about Android Extended Intents.pptx
Nativa Android Applications development
Android Lesson 3 - Intent
Dueling Banjos: Inter-app Communication
Ch5 intent broadcast receivers adapters and internet
Intent, Service and BroadcastReciver (2).ppt
Android development session 2 - intent and activity
W5_Lec09_Lec10_Intents.pptx
Lecture-3.ppt
android.ppt
Android Training - Part 2
Intents in Android
Open Intents - Android Intents Mechanism and Dependency Management
Android overview
Ad

More from Sharafat Ibn Mollah Mosharraf (7)

PPTX
GRP GRM Development Progress Presentation
PDF
Manners Matter: Learning Professional Etiquettes
PPTX
Hibernate collection & association mapping
PDF
Effective Learning (& Teaching)
PDF
Test driven development
PPTX
Android Insights - 3 [Content Providers]
GRP GRM Development Progress Presentation
Manners Matter: Learning Professional Etiquettes
Hibernate collection & association mapping
Effective Learning (& Teaching)
Test driven development
Android Insights - 3 [Content Providers]
Ad

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
August Patch Tuesday
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Getting Started with Data Integration: FME Form 101
PDF
Hybrid model detection and classification of lung cancer
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
Tartificialntelligence_presentation.pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
Architecture types and enterprise applications.pdf
PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Programs and apps: productivity, graphics, security and other tools
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Hindi spoken digit analysis for native and non-native speakers
cloud_computing_Infrastucture_as_cloud_p
Web App vs Mobile App What Should You Build First.pdf
A novel scalable deep ensemble learning framework for big data classification...
August Patch Tuesday
A contest of sentiment analysis: k-nearest neighbor versus neural network
Getting Started with Data Integration: FME Form 101
Hybrid model detection and classification of lung cancer
Zenith AI: Advanced Artificial Intelligence
Tartificialntelligence_presentation.pptx
1. Introduction to Computer Programming.pptx
Architecture types and enterprise applications.pdf
Getting started with AI Agents and Multi-Agent Systems
O2C Customer Invoices to Receipt V15A.pptx
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Chapter 5: Probability Theory and Statistics
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
How ambidextrous entrepreneurial leaders react to the artificial intelligence...

Android Insights - 1 [Intents]

  • 1. Android Insights - 1 Intents
  • 2. Topics to be Covered • Basic Components of Android • Intents & Intent Filters • Intent Resolution 2/8/2012 Android Insights - 1 2/10
  • 3. Basic Components of Android • Activity – provides a screen with which users can interact in order to do something • Service – performs long-running operations in the background and does not provide a user interface • Content Provider – manages access to a structured set of data • Intent – an abstract description of an operation to be performed 2/8/2012 Android Insights - 1 3/10
  • 4. Motivation Towards Intents • We want all the activities, services, broadcast receivers etc. to be loosely-coupled. • Message Passing is the way to go. • Intents are those messages which are used to communicate among the components. Remember? “An intent is an abstract description of an operation to be performed.” 2/8/2012 Android Insights - 1 4/10
  • 5. Primary Structure of an Intent • Action – The general action to be performed • Data – The data to operate on, expressed as a URI. Example of an action-data pair: ACTION_VIEW content://contacts/people/1 Display information about the person whose identifier is "1". 2/8/2012 Android Insights - 1 5/10
  • 6. How Intents Work • Given an arbitrary intent we need to know what to do with it. • This is handled by the process of Intent resolution, which maps an Intent to an Activity, BroadcastReceiver, or Service (or sometimes two or more activities/receivers) that can handle it. • The intent resolution mechanism basically revolves around matching an Intent against all of the <intent- filter> descriptions in the installed application packages. • There is a manifest file in the next slide where activities are marked with the intents they can operate on. 2/8/2012 Android Insights - 1 6/10
  • 7. How Intents Work... What are those category and data elements in intent filters?? 2/8/2012 Android Insights - 1 7/10
  • 8. The Other Parts of Intent • Category – Gives additional information about the action to execute. – For example, CATEGORY_LAUNCHER means it should appear in the Launcher as a top-level application. • Type – Specifies an explicit type (a MIME type) of the intent data. – Normally the type is inferred from the data itself. By setting this attribute, you disable that evaluation and force an explicit type. – For example, setting type to image/jpeg means the activity can handle only jpeg files and not other image files such as png, gif etc. • Extras – A Bundle of any additional information. – Can be used to provide extended information to the component. – For example, an ACTION_HEADSET_PLUG has a "state" extra indicating whether the headset is now plugged in or unplugged, as well as a "name" extra for the type of headset. • Flags – Flags of various sorts. – For example, in the case of FLAG_ACTIVITY_NO_ANIMATION, if set in an Intent passed to Context.startActivity(), this flag will prevent the system from applying an activity transition animation to go to the next activity state. 2/8/2012 Android Insights - 1 8/10
  • 9. Explicit Intents Hey, the Intent-Resolution mechanism of Android is cool, but I just need to start a new activity – that’s all. All those fuzz aren’t worth of merely starting an activity, I guess??? • You’re right. • There is a last part in an intent – Component. • An intent can have specified a component (via setComponent(ComponentName) or setClass(Context, Class)), which provides the exact class to be run. • Often these will not include any other information, simply being a way for an application to launch various internal activities it has as the user interacts with the application. • Intents having components set are called Explicit Intents in contrast to their counterparts Implicit Intents. 2/8/2012 Android Insights - 1 9/10
  • 10. References • Intent Structure and Intent Resolution Mechanism: http://developer.android.com/guide/topics/in tents/intents-filters.html • Standard actions, categories, flags and extra data: http://developer.android.com/reference/andr oid/content/Intent.html 2/8/2012 Android Insights - 1 10/10