SlideShare a Scribd company logo
Todays topics
• The Intent Class
• Starting Activities with Intents
• Explicit Activation
• Implicit Activation via Intent resolution
The Intent Class
• a data structure that represents
1. An operation to be performed, or
2. An event that has occurred
Using Intents to perform Certain Operations
• Intents used to start a single activity
• Intents provide a flexible language for specifying operations to be performed
• Pick a contact
• take a photo
• Dial a phone number
• Open a web-browser
• Open a google map
Android application components can
connect to other Android applications. This
connection is based on a task description
represented by an Intent object
Intents allow you to interact with components from the same
applications as well as with components contributed by other
applications.
For example, an activity can start an external activity for taking
a picture.
In Android the reuse of other application components is a concept known as task. An
application can access other Android components to achieve a task. For example, from a
component of your application you can trigger another component in the Android system,
which manages photos, even if this component is not part of your application
1. Intent is constructed by
one component that
wants some work done
2. Received by one activity
that can perform that
work
• String representing desired operation
Action
Data
Category
Type
Component
Extras
Flags
Action
• String representing desired operation
ACTION_DIAL – Dial a number
ACTION_EDIT – Display data to edit
ACTION_SYNC – Synchronize device data with server
ACTION_MAIN – Start as initial activity of app
ACTION_VIEW: Display the data to the user.
Code
Intent newInt = new Intent();
newInt.setAction(Intent.ACTION_DIAL);
Data
• Data associated with the Intent
• Formatted as a Uniform Resource
Identifier (URI)
• Data to view on a map
• Uri.parse(“geo:0,0?q=1600+Pennsyl
vania+Ave+Washington+DC”)
• Number to dial in the phone dialer
• Uri.parse(“tel:+15555555555”)
Data
• Add’l information associated with
Intent
• Treated as a map (key-value pairs)
Category
• Additional information about the components that can handle the
intent
• Examples
• Category_browsable – can be invoked by a browser to display data
ref’s by a URI
• Category_launcher – can be the initial activity of a task & is listed
in top-level app launcher
Type
• Specifies the MIME type of the Intent data
• examples
• image/*, image/png, image/jpeg , text/html, text/plain
• If unspecified, Android will infer the type
Component
• The component that should
receive this intent
• Use this when there’s exactly
one component that should
receive the intent
Starting Activities for Intents
startActivity(Intent
intent,…)
startActivityForResult(Intent
intent, …)
Target Activity
• Can be named explicitly by setting the intent’s component
• Can be determined implicitly
Intent Resolution
• When the Activity to be
activated is not explicitly
named, Android tries to find
Activities that match the
Intent
• This process is called intent
resolution
Intent Resolution
•An Intent describing a desired operation
•Intent Filters which describe which
operations an Activity can handle Specified
either in AndroidManifest.xml or
programmatically
Intent Resolution Data
Action
Data (both URI & TYPE)
Category
Action
Category
Type
Note: to receive implicit
intents an Activity
should specify an
IntentFilter with the
category
"android.intent.category.
DEFAULT”
Further Syntax

More Related Content

Similar to Intents

Android Insights - 1 [Intents]
Android Insights - 1 [Intents]Android Insights - 1 [Intents]
Android Insights - 1 [Intents]
Sharafat Ibn Mollah Mosharraf
 
Intents are Awesome
Intents are AwesomeIntents are Awesome
Intents are Awesome
Israel Camacho
 
Android App Development 07 : Intent & Share
Android App Development 07 : Intent & ShareAndroid App Development 07 : Intent & Share
Android App Development 07 : Intent & Share
Anuchit Chalothorn
 
Mobile application development
Mobile application developmentMobile application development
Mobile application development
umesh patil
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
Azfar Siddiqui
 
Ch5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internetCh5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internet
Shih-Hsiang Lin
 
Android activity intentsq
Android activity intentsqAndroid activity intentsq
Android activity intentsq
perpetrotech
 
Android activity intents
Android activity intentsAndroid activity intents
Android activity intents
perpetrotech
 
Dueling Banjos: Inter-app Communication
Dueling Banjos: Inter-app Communication Dueling Banjos: Inter-app Communication
Dueling Banjos: Inter-app Communication
Mobile March
 
Yourstory Android Workshop
Yourstory Android WorkshopYourstory Android Workshop
Yourstory Android Workshop
Arvind Devaraj
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
CourseHunt
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in android
Oum Saokosal
 
Session 3 beccse
Session 3 beccseSession 3 beccse
Session 3 beccse
vin123456gangal
 
Hello android world
Hello android worldHello android world
Hello android world
eleksdev
 
Basics 4
Basics   4Basics   4
Basics 4
Michael Shrove
 
Android Training Session 1
Android Training Session 1Android Training Session 1
Android Training Session 1
Shanmugapriya D
 
Android Mobile App Development basics PPT
Android Mobile App Development basics PPTAndroid Mobile App Development basics PPT
Android Mobile App Development basics PPT
nithya697634
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
Can Elmas
 
Best android classes in mumbai
Best android classes in mumbaiBest android classes in mumbai
Best android classes in mumbai
Vibrant Technologies & Computers
 
Android application development
Android application developmentAndroid application development
Android application development
Mayank Bhatt
 

Similar to Intents (20)

Android Insights - 1 [Intents]
Android Insights - 1 [Intents]Android Insights - 1 [Intents]
Android Insights - 1 [Intents]
 
Intents are Awesome
Intents are AwesomeIntents are Awesome
Intents are Awesome
 
Android App Development 07 : Intent & Share
Android App Development 07 : Intent & ShareAndroid App Development 07 : Intent & Share
Android App Development 07 : Intent & Share
 
Mobile application development
Mobile application developmentMobile application development
Mobile application development
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 
Ch5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internetCh5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internet
 
Android activity intentsq
Android activity intentsqAndroid activity intentsq
Android activity intentsq
 
Android activity intents
Android activity intentsAndroid activity intents
Android activity intents
 
Dueling Banjos: Inter-app Communication
Dueling Banjos: Inter-app Communication Dueling Banjos: Inter-app Communication
Dueling Banjos: Inter-app Communication
 
Yourstory Android Workshop
Yourstory Android WorkshopYourstory Android Workshop
Yourstory Android Workshop
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in android
 
Session 3 beccse
Session 3 beccseSession 3 beccse
Session 3 beccse
 
Hello android world
Hello android worldHello android world
Hello android world
 
Basics 4
Basics   4Basics   4
Basics 4
 
Android Training Session 1
Android Training Session 1Android Training Session 1
Android Training Session 1
 
Android Mobile App Development basics PPT
Android Mobile App Development basics PPTAndroid Mobile App Development basics PPT
Android Mobile App Development basics PPT
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Best android classes in mumbai
Best android classes in mumbaiBest android classes in mumbai
Best android classes in mumbai
 
Android application development
Android application developmentAndroid application development
Android application development
 

More from maamir farooq

Ooad lab1
Ooad lab1Ooad lab1
Ooad lab1
maamir farooq
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
maamir farooq
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
maamir farooq
 
Php client libray
Php client librayPhp client libray
Php client libray
maamir farooq
 
Swiftmailer
SwiftmailerSwiftmailer
Swiftmailer
maamir farooq
 
Lect15
Lect15Lect15
Lec 7
Lec 7Lec 7
Lec 6
Lec 6Lec 6
Lec 5
Lec 5Lec 5
J query 1.7 cheat sheet
J query 1.7 cheat sheetJ query 1.7 cheat sheet
J query 1.7 cheat sheet
maamir farooq
 
Assignment
AssignmentAssignment
Assignment
maamir farooq
 
Java script summary
Java script summaryJava script summary
Java script summary
maamir farooq
 
Lec 3
Lec 3Lec 3
Lec 2
Lec 2Lec 2
Lec 1
Lec 1Lec 1
Css summary
Css summaryCss summary
Css summary
maamir farooq
 
Manual of image processing lab
Manual of image processing labManual of image processing lab
Manual of image processing lab
maamir farooq
 
Session management
Session managementSession management
Session management
maamir farooq
 
Data management
Data managementData management
Data management
maamir farooq
 
Content provider
Content providerContent provider
Content provider
maamir farooq
 

More from maamir farooq (20)

Ooad lab1
Ooad lab1Ooad lab1
Ooad lab1
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
Php client libray
Php client librayPhp client libray
Php client libray
 
Swiftmailer
SwiftmailerSwiftmailer
Swiftmailer
 
Lect15
Lect15Lect15
Lect15
 
Lec 7
Lec 7Lec 7
Lec 7
 
Lec 6
Lec 6Lec 6
Lec 6
 
Lec 5
Lec 5Lec 5
Lec 5
 
J query 1.7 cheat sheet
J query 1.7 cheat sheetJ query 1.7 cheat sheet
J query 1.7 cheat sheet
 
Assignment
AssignmentAssignment
Assignment
 
Java script summary
Java script summaryJava script summary
Java script summary
 
Lec 3
Lec 3Lec 3
Lec 3
 
Lec 2
Lec 2Lec 2
Lec 2
 
Lec 1
Lec 1Lec 1
Lec 1
 
Css summary
Css summaryCss summary
Css summary
 
Manual of image processing lab
Manual of image processing labManual of image processing lab
Manual of image processing lab
 
Session management
Session managementSession management
Session management
 
Data management
Data managementData management
Data management
 
Content provider
Content providerContent provider
Content provider
 

Recently uploaded

C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 

Recently uploaded (20)

C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 

Intents

  • 1. Todays topics • The Intent Class • Starting Activities with Intents • Explicit Activation • Implicit Activation via Intent resolution
  • 2. The Intent Class • a data structure that represents 1. An operation to be performed, or 2. An event that has occurred
  • 3. Using Intents to perform Certain Operations • Intents used to start a single activity • Intents provide a flexible language for specifying operations to be performed • Pick a contact • take a photo • Dial a phone number • Open a web-browser • Open a google map Android application components can connect to other Android applications. This connection is based on a task description represented by an Intent object Intents allow you to interact with components from the same applications as well as with components contributed by other applications. For example, an activity can start an external activity for taking a picture.
  • 4.
  • 5. In Android the reuse of other application components is a concept known as task. An application can access other Android components to achieve a task. For example, from a component of your application you can trigger another component in the Android system, which manages photos, even if this component is not part of your application 1. Intent is constructed by one component that wants some work done 2. Received by one activity that can perform that work
  • 6.
  • 7. • String representing desired operation Action Data Category Type Component Extras Flags
  • 8. Action • String representing desired operation ACTION_DIAL – Dial a number ACTION_EDIT – Display data to edit ACTION_SYNC – Synchronize device data with server ACTION_MAIN – Start as initial activity of app ACTION_VIEW: Display the data to the user. Code Intent newInt = new Intent(); newInt.setAction(Intent.ACTION_DIAL);
  • 9. Data • Data associated with the Intent • Formatted as a Uniform Resource Identifier (URI) • Data to view on a map • Uri.parse(“geo:0,0?q=1600+Pennsyl vania+Ave+Washington+DC”) • Number to dial in the phone dialer • Uri.parse(“tel:+15555555555”)
  • 10. Data • Add’l information associated with Intent • Treated as a map (key-value pairs)
  • 11. Category • Additional information about the components that can handle the intent • Examples • Category_browsable – can be invoked by a browser to display data ref’s by a URI • Category_launcher – can be the initial activity of a task & is listed in top-level app launcher
  • 12. Type • Specifies the MIME type of the Intent data • examples • image/*, image/png, image/jpeg , text/html, text/plain • If unspecified, Android will infer the type
  • 13. Component • The component that should receive this intent • Use this when there’s exactly one component that should receive the intent
  • 14. Starting Activities for Intents startActivity(Intent intent,…) startActivityForResult(Intent intent, …)
  • 15. Target Activity • Can be named explicitly by setting the intent’s component • Can be determined implicitly
  • 16. Intent Resolution • When the Activity to be activated is not explicitly named, Android tries to find Activities that match the Intent • This process is called intent resolution
  • 17. Intent Resolution •An Intent describing a desired operation •Intent Filters which describe which operations an Activity can handle Specified either in AndroidManifest.xml or programmatically
  • 18. Intent Resolution Data Action Data (both URI & TYPE) Category
  • 19.
  • 20. Action Category Type Note: to receive implicit intents an Activity should specify an IntentFilter with the category "android.intent.category. DEFAULT”