SlideShare a Scribd company logo
2
Most read
4
Most read
6
Most read
INTENT
Google meaning - intention or purpose.
StackOverFlow - a messaging object you can use to request an action from another
app component
TYPES
Explicit Intents -
You will provide
fully qualified name
of component to
start
-Within your app
01
Implicit Intents –
You will provide
action to perform
system starts the
action.
02
INTENT USAGES
• To start components.
• To share data.
EXAMPLES
Implicit Intent
• // Create the text message with a string
• Intent sendIntent = new Intent();
• sendIntent.setAction(Intent.ACTION_SEND);
• sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
• sendIntent.setType("text/plain");
• //sendIntent.setType("text/plain");
• // Verify that the intent will resolve to an activity
• if (sendIntent.resolveActivity(getPackageManager()) != null) {
• startActivity(sendIntent);
• }
Explicit Intent
• startActivity(new
Intent(Mainactivity.this,SecondActivity.class));
HOW TO RECEIVE INTENTS
• Using intent-filters. <intent-filter/>
• To receive plain text :
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
HANDLING INCOMING INTENTS
onCreate (Bundle savedInstanceState) {
...
// Get intent, action and MIME type
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
handleSendText(intent); // Handle text being sent
} else if (type.startsWith("image/")) {
handleSendImage(intent); // Handle single image being sent
}
}
}
INTENT RESOLUTION
• Action.
• Data (both URI and data type).
• Category.

More Related Content

PPTX
05 intent
PDF
Android intents
PPTX
Android - Intents - Mazenet Solution
PPT
Android - Android Intent Types
PDF
Android intent
PDF
Android Lesson 3 - Intent
PPTX
B2. activity and intent
PDF
Android Introduction
05 intent
Android intents
Android - Intents - Mazenet Solution
Android - Android Intent Types
Android intent
Android Lesson 3 - Intent
B2. activity and intent
Android Introduction

What's hot (20)

PPT
Android Bootcamp Tanzania:intents
PPTX
Android development session 2 - intent and activity
DOCX
Android intents in android application-chapter7
PDF
Android App Development 07 : Intent &amp; Share
PDF
Intents in Android
PDF
PDF
Android: Intent, Intent Filter, Broadcast Receivers
ODP
Android App Development - 02 Activity and intent
PPTX
Develop a native application that uses GPS location.pptx
PPTX
Advance Java Programming(CM5I) Event handling
PPT
Java eventhandling
PPTX
Event handling in Java(part 1)
DOCX
Código Acerca Editor_Net
PDF
Smart Join Algorithms for Fighting Skew at Scale
PPTX
Event Handling in JAVA
PPTX
Event Handling in Java
PPTX
Event Handling in java
PPTX
Event handling
PPTX
When life gives you functions make functional programs!
Android Bootcamp Tanzania:intents
Android development session 2 - intent and activity
Android intents in android application-chapter7
Android App Development 07 : Intent &amp; Share
Intents in Android
Android: Intent, Intent Filter, Broadcast Receivers
Android App Development - 02 Activity and intent
Develop a native application that uses GPS location.pptx
Advance Java Programming(CM5I) Event handling
Java eventhandling
Event handling in Java(part 1)
Código Acerca Editor_Net
Smart Join Algorithms for Fighting Skew at Scale
Event Handling in JAVA
Event Handling in Java
Event Handling in java
Event handling
When life gives you functions make functional programs!
Ad

Similar to Android Intent and intent filters (20)

PPT
Intent, Service and BroadcastReciver (2).ppt
PPTX
unit3.pptx
PPT
Types of intents in android application development
PPTX
08.1. Android How to Use Intent (explicit)
PPTX
Espresso workshop
PDF
Intents are Awesome
PDF
Lab1-android
PPTX
Android - Intents and Filters hgfh gfh.pptx
PPTX
Android activity intentsq
PPTX
Android activity intents
PPTX
Tk2323 lecture 3 intent
PPTX
Pertemuan 03 - Activities and intents.pptx
PPTX
Data Transfer between activities and Database
PPTX
Android webinar class_3
PPTX
Unit 5 Activity and Activity Life Cycle.pptx
PDF
Android programming introduction
PDF
Android Basic Components
PPTX
PPTX
Data Transfer between Activities & Databases
DOCX
Using intents in android
Intent, Service and BroadcastReciver (2).ppt
unit3.pptx
Types of intents in android application development
08.1. Android How to Use Intent (explicit)
Espresso workshop
Intents are Awesome
Lab1-android
Android - Intents and Filters hgfh gfh.pptx
Android activity intentsq
Android activity intents
Tk2323 lecture 3 intent
Pertemuan 03 - Activities and intents.pptx
Data Transfer between activities and Database
Android webinar class_3
Unit 5 Activity and Activity Life Cycle.pptx
Android programming introduction
Android Basic Components
Data Transfer between Activities & Databases
Using intents in android
Ad

Recently uploaded (20)

PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
E -tech empowerment technologies PowerPoint
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPTX
innovation process that make everything different.pptx
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPTX
Introduction to Information and Communication Technology
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPTX
SAP Ariba Sourcing PPT for learning material
DOCX
Unit-3 cyber security network security of internet system
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PPTX
international classification of diseases ICD-10 review PPT.pptx
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPTX
artificial intelligence overview of it and more
PDF
Introduction to the IoT system, how the IoT system works
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PDF
Paper PDF World Game (s) Great Redesign.pdf
introduction about ICD -10 & ICD-11 ppt.pptx
E -tech empowerment technologies PowerPoint
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
innovation process that make everything different.pptx
Tenda Login Guide: Access Your Router in 5 Easy Steps
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Introduction to Information and Communication Technology
Design_with_Watersergyerge45hrbgre4top (1).ppt
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
SAP Ariba Sourcing PPT for learning material
Unit-3 cyber security network security of internet system
RPKI Status Update, presented by Makito Lay at IDNOG 10
international classification of diseases ICD-10 review PPT.pptx
Job_Card_System_Styled_lorem_ipsum_.pptx
artificial intelligence overview of it and more
Introduction to the IoT system, how the IoT system works
Power Point - Lesson 3_2.pptx grad school presentation
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PptxGenJS_Demo_Chart_20250317130215833.pptx
Paper PDF World Game (s) Great Redesign.pdf

Android Intent and intent filters

  • 1. INTENT Google meaning - intention or purpose. StackOverFlow - a messaging object you can use to request an action from another app component
  • 2. TYPES Explicit Intents - You will provide fully qualified name of component to start -Within your app 01 Implicit Intents – You will provide action to perform system starts the action. 02
  • 3. INTENT USAGES • To start components. • To share data.
  • 4. EXAMPLES Implicit Intent • // Create the text message with a string • Intent sendIntent = new Intent(); • sendIntent.setAction(Intent.ACTION_SEND); • sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage); • sendIntent.setType("text/plain"); • //sendIntent.setType("text/plain"); • // Verify that the intent will resolve to an activity • if (sendIntent.resolveActivity(getPackageManager()) != null) { • startActivity(sendIntent); • } Explicit Intent • startActivity(new Intent(Mainactivity.this,SecondActivity.class));
  • 5. HOW TO RECEIVE INTENTS • Using intent-filters. <intent-filter/> • To receive plain text : <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter>
  • 6. HANDLING INCOMING INTENTS onCreate (Bundle savedInstanceState) { ... // Get intent, action and MIME type Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { handleSendText(intent); // Handle text being sent } else if (type.startsWith("image/")) { handleSendImage(intent); // Handle single image being sent } } }
  • 7. INTENT RESOLUTION • Action. • Data (both URI and data type). • Category.