SlideShare a Scribd company logo
1 of 23
Download to read offline
Israel Ferrer
  Android Lover since 2008
     cofounder bubiloop
    cofounder android.es
  Barcelona GTUG Leader
   Android Dev at Fever
Head Mobile Dept. at ASMWS
 Computer Science at LaSalle
INTENTS
ARE AWESOME
   really, trust me!



                       Israel Ferrer
                            14th March
WHAT ARE

INTENTS
    ?
intent |inˈtent| noun
 intention or purpose:
with alarm she realized his
intent | a real intent to cut back
on social programs.




                                     flickr: chinesetealover
OK... WHAT DOES THIS REALLY MEAN?
Open new Screens
   Share with other apps
Open Camera to take a photo
    Open file manager
    Open the browser
  Open QR Code Scanner
             ...
HOW INTENTS

WORK
     ?
Explicit Intent


Implicit Intent



                  theatricalintelligence
EXPLICIT INTENTS

• Explicit
         Intent names the component which should be called
 by the Android system, using the Java class as identifier.

• Used   to open new activities in the same app.
         final Intent intent=new Intent(this, LoginActivity.class);
         startActivity(intent);
IMPLICIT INTENTS
• Implicitintent specifies the action to perform and optionally an
  URI for the action.

• Implicit
         Intent is managed by Android Intent resolution, which
  maps the intent to a Service, Activity or Broadcasts Receiver

• Thisresolution is done by matching intent with intentFilters of
  every app.

• Ifmore than one app can handle the action, the user will have
  to choose.
       final Intent intent=new Intent(Intent.ACTION_VIEW, "http://mylookout.com");
SHARE DATA

• Intents        can contain aditional data by using putExtra() method
  •       intent.putExtra(EXTRA_CONVERSATION, conversation);



• the
    receiving component can obtain this data by getExtras()
 method
      Bundle extras = getIntent().getExtras();
      String conversation = extras.getString(EXTRA_CONVERSATION);
      if (conversation != null) {
      	 // Do something with the data
      }
INTENT FILTERS
• AnIntentFilter specifies the types of Intent that an activity,
 service, or broadcast receiver can respond to. IntentFilters are
 declared in the Android Manifest.

• There   are 3 pieces of information used for this resolution:

 • Action

 • Type: mymeType      or scheme.

 • Category: need    to support DEFAULT to be found by
   startActivity.
INTENT FILTERS
Intent
final Intent intent=new Intent(Intent.ACTION_VIEW, "http://mylookout.com");



IntentFilter
<activity android:name=".BrowserActivitiy" android:label="@string/app_name">
  <intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <data android:scheme="http"/>
  </intent-filter>
</activity>
TO SUM UP

• Explicit: choose    the component to call.

• Implicit: isa general intent with action and optionally URI.
 The Intent resolution call the component that can handle it.

• Intents   can share data between components and apps.
HOW TO

USE
INTENTS
   ?
• Reuse   code and functionality from 3rd party apps

 • ACTION_SEND

 • ACTION_VIEW

   • geo:lat,lon   to open map

   • http://host   to open browser

   • tel:number    to open dialer
• Define    a set of intents to handle web addresses.

• Example: Twitter

  • Define    IntentFilter to handle twitter urls

   <activity android:name=".UrlHandleActivity" android:label="@string/app_name">
     <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:host="www.twitter.com" android:scheme="http" />
     </intent-filter>
   </activity>
• Check   the URL path to fire target Activity
   public void onCreate(Bundle savedInstanceState)
   	   {
   	     super.onCreate(savedInstanceState);
   	
   	     Uri uri = getIntent().getData();
   	     if (null == uri) {
   	       // Shouldn't happen. Handle errors.
   	       finish();
   	       return;
   	     }

   	    String path = uri.getPath();
   	    for (Pair<String, Class> pair : DISPATCH_MAP) {
   	      if (path.matches(pair.mFirst)) {
   	        Intent intent = new Intent(this, pair.mSecond);
   	        intent.setData(uri);
   	        startActivity(intent);
   	        finish();
   	        return;
   	      }
   	    }
   	   	    finish();
   	   }
   	   private static final List<Pair<String, Class>> DISPATCH_MAP
       = new LinkedList<Pair<String, Class>>();
   static {
     DISPATCH_MAP.add(new Pair<String, Class>("(.*)/status$",
       TweetActivity.class));
     DISPATCH_MAP.add(new Pair<String, Class>("/another/path",
       ProfileActivity.class));
   }
• Exposeintents to 3rd party apps. Example: Lookout public
 backup intent.
CONCLUSIONS
A core component of Android.
 A way to reuse functionality between apps.
         The glue between activities.
The mashup concept into a mobile platform
Intents are Awesome for users & developers
QUESTIONS?
Intents are Awesome

More Related Content

What's hot

Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recievers
Utkarsh Mankad
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycle
Ahsanul Karim
 
Android activity
Android activityAndroid activity
Android activity
Krazy Koder
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
Utkarsh Mankad
 

What's hot (19)

Using intents in android
Using intents in androidUsing intents in android
Using intents in android
 
Presentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestatePresentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestate
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Android Components
Android ComponentsAndroid Components
Android Components
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Event handling in Java(part 2)
Event handling in Java(part 2)Event handling in Java(part 2)
Event handling in Java(part 2)
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recievers
 
Android components
Android componentsAndroid components
Android components
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycle
 
Event handling in Java(part 1)
Event handling in Java(part 1)Event handling in Java(part 1)
Event handling in Java(part 1)
 
Events and Listeners in Android
Events and Listeners in AndroidEvents and Listeners in Android
Events and Listeners in Android
 
Android Components & Manifest
Android Components & ManifestAndroid Components & Manifest
Android Components & Manifest
 
Android activity
Android activityAndroid activity
Android activity
 
Android
AndroidAndroid
Android
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
Lab1-android
Lab1-androidLab1-android
Lab1-android
 

Viewers also liked

Viewers also liked (10)

Android intent
Android intentAndroid intent
Android intent
 
Android intents
Android intentsAndroid intents
Android intents
 
Android Lecture #01 @PRO&BSC Inc.
Android Lecture #01 @PRO&BSC Inc.Android Lecture #01 @PRO&BSC Inc.
Android Lecture #01 @PRO&BSC Inc.
 
Level 1 &amp; 2
Level 1 &amp; 2Level 1 &amp; 2
Level 1 &amp; 2
 
Intent in android
Intent in androidIntent in android
Intent in android
 
Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast Receivers
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - Intent
 
Android - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionAndroid - Intents - Mazenet Solution
Android - Intents - Mazenet Solution
 
Android ppt
Android ppt Android ppt
Android ppt
 

Similar to Intents are Awesome

Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
AbdullahMunir32
 
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
aswinbiju1652
 
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 webinar class_3
Android webinar class_3Android webinar class_3
Android webinar class_3
Edureka!
 

Similar to Intents are Awesome (20)

Android intents in android application-chapter7
Android intents in android application-chapter7Android intents in android application-chapter7
Android intents in android application-chapter7
 
ANDROID
ANDROIDANDROID
ANDROID
 
Data Transfer between activities and Database
Data Transfer between activities and Database Data Transfer between activities and Database
Data Transfer between activities and Database
 
unit3.pptx
unit3.pptxunit3.pptx
unit3.pptx
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
Android - Android Intent Types
Android - Android Intent TypesAndroid - Android Intent Types
Android - Android Intent Types
 
Activity & Shared Preference
Activity & Shared PreferenceActivity & Shared Preference
Activity & Shared Preference
 
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
 
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 webinar class_3
Android webinar class_3Android webinar class_3
Android webinar class_3
 
How to integrate flurry in android
How to integrate flurry in androidHow to integrate flurry in android
How to integrate flurry in android
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.ppt
 
Hieu Xamarin iOS9, Android M 3-11-2015
Hieu Xamarin iOS9, Android M  3-11-2015Hieu Xamarin iOS9, Android M  3-11-2015
Hieu Xamarin iOS9, Android M 3-11-2015
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).ppt
 
Tk2323 lecture 3 intent
Tk2323 lecture 3   intentTk2323 lecture 3   intent
Tk2323 lecture 3 intent
 
Android Activities.pdf
Android Activities.pdfAndroid Activities.pdf
Android Activities.pdf
 
Pertemuan 03 - Activities and intents.pptx
Pertemuan 03 - Activities and intents.pptxPertemuan 03 - Activities and intents.pptx
Pertemuan 03 - Activities and intents.pptx
 
Hello android world
Hello android worldHello android world
Hello android world
 

Recently uploaded

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Recently uploaded (20)

Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 

Intents are Awesome

  • 1. Israel Ferrer Android Lover since 2008 cofounder bubiloop cofounder android.es Barcelona GTUG Leader Android Dev at Fever Head Mobile Dept. at ASMWS Computer Science at LaSalle
  • 2. INTENTS ARE AWESOME really, trust me! Israel Ferrer 14th March
  • 4. intent |inˈtent| noun intention or purpose: with alarm she realized his intent | a real intent to cut back on social programs. flickr: chinesetealover
  • 5. OK... WHAT DOES THIS REALLY MEAN?
  • 6. Open new Screens Share with other apps Open Camera to take a photo Open file manager Open the browser Open QR Code Scanner ...
  • 8. Explicit Intent Implicit Intent theatricalintelligence
  • 9. EXPLICIT INTENTS • Explicit Intent names the component which should be called by the Android system, using the Java class as identifier. • Used to open new activities in the same app. final Intent intent=new Intent(this, LoginActivity.class); startActivity(intent);
  • 10. IMPLICIT INTENTS • Implicitintent specifies the action to perform and optionally an URI for the action. • Implicit Intent is managed by Android Intent resolution, which maps the intent to a Service, Activity or Broadcasts Receiver • Thisresolution is done by matching intent with intentFilters of every app. • Ifmore than one app can handle the action, the user will have to choose. final Intent intent=new Intent(Intent.ACTION_VIEW, "http://mylookout.com");
  • 11. SHARE DATA • Intents can contain aditional data by using putExtra() method • intent.putExtra(EXTRA_CONVERSATION, conversation); • the receiving component can obtain this data by getExtras() method Bundle extras = getIntent().getExtras(); String conversation = extras.getString(EXTRA_CONVERSATION); if (conversation != null) { // Do something with the data }
  • 12. INTENT FILTERS • AnIntentFilter specifies the types of Intent that an activity, service, or broadcast receiver can respond to. IntentFilters are declared in the Android Manifest. • There are 3 pieces of information used for this resolution: • Action • Type: mymeType or scheme. • Category: need to support DEFAULT to be found by startActivity.
  • 13. INTENT FILTERS Intent final Intent intent=new Intent(Intent.ACTION_VIEW, "http://mylookout.com"); IntentFilter <activity android:name=".BrowserActivitiy" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http"/> </intent-filter> </activity>
  • 14. TO SUM UP • Explicit: choose the component to call. • Implicit: isa general intent with action and optionally URI. The Intent resolution call the component that can handle it. • Intents can share data between components and apps.
  • 16. • Reuse code and functionality from 3rd party apps • ACTION_SEND • ACTION_VIEW • geo:lat,lon to open map • http://host to open browser • tel:number to open dialer
  • 17. • Define a set of intents to handle web addresses. • Example: Twitter • Define IntentFilter to handle twitter urls <activity android:name=".UrlHandleActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:host="www.twitter.com" android:scheme="http" /> </intent-filter> </activity>
  • 18. • Check the URL path to fire target Activity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Uri uri = getIntent().getData(); if (null == uri) { // Shouldn't happen. Handle errors. finish(); return; } String path = uri.getPath(); for (Pair<String, Class> pair : DISPATCH_MAP) { if (path.matches(pair.mFirst)) { Intent intent = new Intent(this, pair.mSecond); intent.setData(uri); startActivity(intent); finish(); return; } } finish(); } private static final List<Pair<String, Class>> DISPATCH_MAP = new LinkedList<Pair<String, Class>>(); static { DISPATCH_MAP.add(new Pair<String, Class>("(.*)/status$", TweetActivity.class)); DISPATCH_MAP.add(new Pair<String, Class>("/another/path", ProfileActivity.class)); }
  • 19. • Exposeintents to 3rd party apps. Example: Lookout public backup intent.
  • 21. A core component of Android. A way to reuse functionality between apps. The glue between activities. The mashup concept into a mobile platform Intents are Awesome for users & developers