SlideShare una empresa de Scribd logo
1 de 10
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

Más contenido relacionado

Similar a Android Insights - 1 [Intents]

04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)
TECOS
 
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkkSWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
erenakarsu1
 
Android application model
Android application modelAndroid application model
Android application model
magicshui
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
MugiiiReee
 
Yourstory Android Workshop
Yourstory Android WorkshopYourstory Android Workshop
Yourstory Android Workshop
Arvind Devaraj
 

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

ANDROID
ANDROIDANDROID
ANDROID
 
Android intent
Android intentAndroid intent
Android intent
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).ppt
 
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 Application Components
Android Application ComponentsAndroid Application Components
Android Application Components
 
Kotlin for Android App Development Presentation
Kotlin for Android App Development PresentationKotlin for Android App Development Presentation
Kotlin for Android App Development Presentation
 
Unit - III.pptx
Unit - III.pptxUnit - III.pptx
Unit - III.pptx
 
Android Training (android fundamental)
Android Training (android fundamental)Android Training (android fundamental)
Android Training (android fundamental)
 
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkkSWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
 
Basics 4
Basics   4Basics   4
Basics 4
 
Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentals
 
Android Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsAndroid Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intents
 
Android application model
Android application modelAndroid application model
Android application model
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3
 
Android session 2
Android session 2Android session 2
Android session 2
 
Android beginners David
Android beginners DavidAndroid beginners David
Android beginners David
 
Yourstory Android Workshop
Yourstory Android WorkshopYourstory Android Workshop
Yourstory Android Workshop
 

Más de Sharafat Ibn Mollah Mosharraf

Más de Sharafat Ibn Mollah Mosharraf (7)

GRP GRM Development Progress Presentation
GRP GRM Development Progress PresentationGRP GRM Development Progress Presentation
GRP GRM Development Progress Presentation
 
Manners Matter: Learning Professional Etiquettes
Manners Matter: Learning Professional EtiquettesManners Matter: Learning Professional Etiquettes
Manners Matter: Learning Professional Etiquettes
 
SQL
SQLSQL
SQL
 
Hibernate collection & association mapping
Hibernate collection & association mappingHibernate collection & association mapping
Hibernate collection & association mapping
 
Effective Learning (& Teaching)
Effective Learning (& Teaching)Effective Learning (& Teaching)
Effective Learning (& Teaching)
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Android Insights - 3 [Content Providers]
Android Insights - 3 [Content Providers]Android Insights - 3 [Content Providers]
Android Insights - 3 [Content Providers]
 

Último

Último (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

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