SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
Android Intents
Agenda
What is Intent?
Why Intent?
Types of Intents?
How Intents are received?
How Intents are resolved?
What is an Intent?
➢ Intent is an intention to do something.
➢ Intent contains an action carrying some
information.
➢ Intent is used to communicate between
android components.
○ To start an activity
○ To start a service
○ To deliver a broadcast.
Why Intent?
➢ Intent is used to communicate, share data
between components.
➢ Intent contains the following things.
○ Component Name
○ Action
○ Data
○ Extras
○ Category
○ Flags
Types of Intents?
➢ Explicit Intents
➢ Implicit Intents
Explicit Intents
➢ Used to launch a specific component like
activity or a service.
➢ In this case, android system directly
forwards this intent to that specific
component.
➢ It is faster.
➢ Always use explicit intents if you know the
specific activity or service that performs
Explicit Intents
➢ To Create Explicit intents
// Executed in an Activity, so 'this' is the Context
// The fileUrl is a string URL, such as "http://www.example.com/image.png"
Intent downloadIntent = new Intent(this, DownloadService.class);
downloadIntent.setData(Uri.parse(fileUrl));
startService(downloadIntent);
Implicit Intent
➢ Specifies an action that can invoke an app
on the device that can perform the action.
➢ Useful when your app can not perform the
action but other apps do and you let user to
pick up the app.
➢ Its possible that there may not be any app
that handles the implicit intent.
Implicit Intent
Ex:
// Create the text message with a string
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type
// Verify that the intent will resolve to an activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(sendIntent);
}
How Intents are received?
➢ Till now we have seen how intents are used
to invoke some other components. Now lets
explore how these components receive
these intents.
➢ Receiving Implicit Intents
➢ Receiving Explicit Intents
○ Explicit Intents are directly delivered to target as
intent has the target component class specified in it.
Receiving Implicit Intents
➢ Your app should advertise what intents it can
handle using <intent-filter> tag in the
manifest file under <activity> or <service> or
<receiver> tags.
➢ You can mention one or more of these three
elements under <intent-filter>
○ action
○ data
○ category
Receiving Implicit Intents
Ex:
<activity android:name="ShareActivity">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
How Intents are resolved?
➢ When the system receives an implicit intent,
it searches the component by comparing the
intent to intent filter based on these aspects.
○ The Intent action(Action Test)
■ Ex: ACTION_SEND
○ The Intent Category(Category Test)
■ Ex: CATEGORY_HOME
○ The Data(Data Test)
■ Ex: android:mimetype=”video/mpeg”
Further Study
➢ Explore on Pending Intents.
➢ Writing your own intent chooser.

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Fragment
Fragment Fragment
Fragment
 
Broadcast Receivers in Android
Broadcast Receivers in AndroidBroadcast Receivers in Android
Broadcast Receivers in Android
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
 
Android Services
Android ServicesAndroid Services
Android Services
 
Android - Android Intent Types
Android - Android Intent TypesAndroid - Android Intent Types
Android - Android Intent Types
 
Android Widget
Android WidgetAndroid Widget
Android Widget
 
04 activities and activity life cycle
04 activities and activity life cycle04 activities and activity life cycle
04 activities and activity life cycle
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
android layouts
android layoutsandroid layouts
android layouts
 
Activity lifecycle
Activity lifecycleActivity lifecycle
Activity lifecycle
 
Menu bars and menus
Menu bars and menusMenu bars and menus
Menu bars and menus
 
Android Location and Maps
Android Location and MapsAndroid Location and Maps
Android Location and Maps
 
Android User Interface
Android User InterfaceAndroid User Interface
Android User Interface
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast Receivers
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 

Ähnlich wie Android intents

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 Intent and intent filters
Android Intent and intent filtersAndroid Intent and intent filters
Android Intent and intent filtersGowtham Kumar
 
Android Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsAndroid Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsDenis Minja
 
Android App Development 07 : Intent &amp; Share
Android App Development 07 : Intent &amp; ShareAndroid App Development 07 : Intent &amp; Share
Android App Development 07 : Intent &amp; ShareAnuchit Chalothorn
 
Tk2323 lecture 3 intent
Tk2323 lecture 3   intentTk2323 lecture 3   intent
Tk2323 lecture 3 intentMengChun Lam
 
Android - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionAndroid - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionMazenetsolution
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & DatabasesMuhammad Sajid
 
Android Studio Tutorial For Beginners -2 | Android Development Tutorial | And...
Android Studio Tutorial For Beginners -2 | Android Development Tutorial | And...Android Studio Tutorial For Beginners -2 | Android Development Tutorial | And...
Android Studio Tutorial For Beginners -2 | Android Development Tutorial | And...Edureka!
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptBirukMarkos
 
android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semaswinbiju1652
 
W5_Lec09_Lec10_Intents.pptx
W5_Lec09_Lec10_Intents.pptxW5_Lec09_Lec10_Intents.pptx
W5_Lec09_Lec10_Intents.pptxChSalmanSalman
 
Android webinar class_3
Android webinar class_3Android webinar class_3
Android webinar class_3Edureka!
 
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 internetShih-Hsiang Lin
 
Android App Development - 02 Activity and intent
Android App Development - 02 Activity and intentAndroid App Development - 02 Activity and intent
Android App Development - 02 Activity and intentDiego Grancini
 

Ähnlich wie Android intents (20)

unit3.pptx
unit3.pptxunit3.pptx
unit3.pptx
 
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 intents in android application-chapter7
Android intents in android application-chapter7Android intents in android application-chapter7
Android intents in android application-chapter7
 
Android Intent and intent filters
Android Intent and intent filtersAndroid Intent and intent filters
Android Intent and intent filters
 
Android Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsAndroid Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intents
 
Android App Development 07 : Intent &amp; Share
Android App Development 07 : Intent &amp; ShareAndroid App Development 07 : Intent &amp; Share
Android App Development 07 : Intent &amp; Share
 
Tk2323 lecture 3 intent
Tk2323 lecture 3   intentTk2323 lecture 3   intent
Tk2323 lecture 3 intent
 
Android - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionAndroid - Intents - Mazenet Solution
Android - Intents - Mazenet Solution
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
Lab1-android
Lab1-androidLab1-android
Lab1-android
 
Android Studio Tutorial For Beginners -2 | Android Development Tutorial | And...
Android Studio Tutorial For Beginners -2 | Android Development Tutorial | And...Android Studio Tutorial For Beginners -2 | Android Development Tutorial | And...
Android Studio Tutorial For Beginners -2 | Android Development Tutorial | And...
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).ppt
 
Intents are Awesome
Intents are AwesomeIntents are Awesome
Intents are Awesome
 
android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last sem
 
W5_Lec09_Lec10_Intents.pptx
W5_Lec09_Lec10_Intents.pptxW5_Lec09_Lec10_Intents.pptx
W5_Lec09_Lec10_Intents.pptx
 
ANDROID
ANDROIDANDROID
ANDROID
 
Android webinar class_3
Android webinar class_3Android webinar class_3
Android webinar class_3
 
Android development session 2 - intent and activity
Android development   session 2 - intent and activityAndroid development   session 2 - intent and activity
Android development session 2 - intent and activity
 
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 App Development - 02 Activity and intent
Android App Development - 02 Activity and intentAndroid App Development - 02 Activity and intent
Android App Development - 02 Activity and intent
 

Kürzlich hochgeladen

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Kürzlich hochgeladen (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

Android intents

  • 2. Agenda What is Intent? Why Intent? Types of Intents? How Intents are received? How Intents are resolved?
  • 3. What is an Intent? ➢ Intent is an intention to do something. ➢ Intent contains an action carrying some information. ➢ Intent is used to communicate between android components. ○ To start an activity ○ To start a service ○ To deliver a broadcast.
  • 4. Why Intent? ➢ Intent is used to communicate, share data between components. ➢ Intent contains the following things. ○ Component Name ○ Action ○ Data ○ Extras ○ Category ○ Flags
  • 5. Types of Intents? ➢ Explicit Intents ➢ Implicit Intents
  • 6. Explicit Intents ➢ Used to launch a specific component like activity or a service. ➢ In this case, android system directly forwards this intent to that specific component. ➢ It is faster. ➢ Always use explicit intents if you know the specific activity or service that performs
  • 7. Explicit Intents ➢ To Create Explicit intents // Executed in an Activity, so 'this' is the Context // The fileUrl is a string URL, such as "http://www.example.com/image.png" Intent downloadIntent = new Intent(this, DownloadService.class); downloadIntent.setData(Uri.parse(fileUrl)); startService(downloadIntent);
  • 8. Implicit Intent ➢ Specifies an action that can invoke an app on the device that can perform the action. ➢ Useful when your app can not perform the action but other apps do and you let user to pick up the app. ➢ Its possible that there may not be any app that handles the implicit intent.
  • 9. Implicit Intent Ex: // Create the text message with a string Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage); sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type // Verify that the intent will resolve to an activity if (sendIntent.resolveActivity(getPackageManager()) != null) { startActivity(sendIntent); }
  • 10. How Intents are received? ➢ Till now we have seen how intents are used to invoke some other components. Now lets explore how these components receive these intents. ➢ Receiving Implicit Intents ➢ Receiving Explicit Intents ○ Explicit Intents are directly delivered to target as intent has the target component class specified in it.
  • 11. Receiving Implicit Intents ➢ Your app should advertise what intents it can handle using <intent-filter> tag in the manifest file under <activity> or <service> or <receiver> tags. ➢ You can mention one or more of these three elements under <intent-filter> ○ action ○ data ○ category
  • 12. Receiving Implicit Intents Ex: <activity android:name="ShareActivity"> <intent-filter> <action android:name="android.intent.action.SEND"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="text/plain"/> </intent-filter> </activity>
  • 13. How Intents are resolved? ➢ When the system receives an implicit intent, it searches the component by comparing the intent to intent filter based on these aspects. ○ The Intent action(Action Test) ■ Ex: ACTION_SEND ○ The Intent Category(Category Test) ■ Ex: CATEGORY_HOME ○ The Data(Data Test) ■ Ex: android:mimetype=”video/mpeg”
  • 14. Further Study ➢ Explore on Pending Intents. ➢ Writing your own intent chooser.