SlideShare a Scribd company logo
1 of 18
Download to read offline
Intents &
Intent Filters
   codeandroid.org
Intents & Intents Filter

• Intents : request for an action to be
  performed (usually on a set of data)
• Intent Filters : register Activities, Services,
  and Broadcast Receivers (as being capable
  of performing an action on a set of data)
• Broadcast Receivers : listens to intents
Intents

• Support interaction between any
  application components available on an
  Android device
   • start a new Activity
   • broadcast messages (broadcast intents)
Intents
       Starting a new Activity

Intent intent = new Intent (......................);
startActivity(intent);
Intents
                   Starting a new Activity
Dial a number

Intent intent = new Intent (Intent.ACTION_DIAL, Uri.parse(“tel:93675359”));
startActivity(intent);

Launch a website

Intent intent = new Intent (Intent.ACTION_VIEW, Uri.parse(“http://codeandroid.org”));
startActivity(intent);
Intents
                     Starting a new Activity
Launch an Activity

 Intent intent = new Intent (this, HelloWorld.class);
 startActivity(intent);

Launch an Activity
 Intent intent = new Intent (this, HelloWorld.class);
 intent.putExtra(“title”,”Hello codeandroid”);
 startActivity(intent);
Intent Filters
AndroidManifest.xml

<activity android:name=”.HelloWorld”
          android:label=”@string/app_name”>
          <intent-filter>
               <action android:name=”android.intent.action.MAIN”/>
               <category android:name=”android.intent.category.LAUNCHER”/>
          </intent-filter>
</activity>

Launch Hello World

Intent intent = new Intent (this, HelloWorld.class);
startActivity(intent);
Intent Filters

• Required for Intent resolution to
  match Intents to Activities, Services, or
  BroadcastReceivers
• Most Intent Filters are declared in
  AndroidManifest.xml of an application
Intent Filters
AndroidManifest.xml

<activity android:name=”.HelloWorld”
          android:label=”@string/app_name”>
          <intent-filter>
               <action android:name=”org.codeandroid.intentstest.HelloWorld”/>
               <category android:name=”android.intent.category.DEFAULT”/>
          </intent-filter>
</activity>

Launch Hello World

Intent intent = new Intent (“org.codeandroid.intentstest.HelloWorld”);
startActivity(intent);
Intent Filters
AndroidManifest.xml
<activity android:name=”.HelloWorld”
           android:label=”@string/app_name”>
           <intent-filter>
                <action android:name=”android.intent.action.VIEW”/>
                <category android:name=”android.intent.category.DEFAULT”/>
                <category android:name=”android.intent.category.BROWSABLE”/>
                <data android:scheme=”http” android:host=”androidium.org”/>
           </intent-filter>
</activity>
Launch Hello World

Intent intent = new Intent (Intent.ACTION_VIEW, Uri.parse(“http://androidium.org”));
startActivity(intent);
Intent Filters
AndroidManifest.xml

<activity android:name=”.HelloWorld”
           android:label=”@string/app_name”>
           <intent-filter>
                <action android:name=”android.intent.action.VIEW”/>
                <category android:name=”android.intent.category.DEFAULT”/>
                <category android:name=”android.intent.category.BROWSABLE”/>
                <data android:scheme=”http”
                     android:host=”www.google.com”
                     android:pathPrefix=”/advanced_search”
                />
           </intent-filter>
</activity>
Intent Filters
AndroidManifest.xml
<activity android:name=”.HelloWorld”
           android:label=”@string/app_name”>
           <intent-filter>
                <action android:name=”android.intent.action.VIEW”/>
                <category android:name=”android.intent.category.DEFAULT”/>
                <category android:name=”android.intent.category.BROWSABLE”/>
                <data android:scheme=”codeandroid”/>
           </intent-filter>
</activity>
Launch Hello World

Intent intent = new Intent (Intent.ACTION_VIEW, Uri.parse(“codeandroid://”));
startActivity(intent);
Intents
               Launch the Android Market

Uri marketUri = Uri.parse(“http://market.android.com/search?q=pname:com.buuuk.buUuk”)
Intent intent = new Intent (Intent.ACTION_VIEW, marketUri);
startActivity(intent);



Uri marketUri = Uri.parse(“market://search?q=pname:com.buuuk.buUuk”)
Intent intent = new Intent (Intent.ACTION_VIEW, marketUri);
startActivity(intent);
Intents
      Broadcast Intents

• broadcast messages between
  components with the sendBroadcast
  method
• makes an application more open, by
  broadcasting to current and other
  applications
Intents
             Broadcast Intents


Intent intent = new
Intent(“org.codeandroid.intentstest.TestBroadcastReceiver”);
sendBroadcast(intent);
Broadcast Receivers

• listen to Broadcast Intents
• must be registered (either in code or
  within the app manifest
• use Intent Filter to specify which
  Intents it is listening for
Broadcast Receivers
                             registered inside code
IntentFilter filter = new IntentFilter(“org.codeandroid.intentstest.TestBroadcastReceiver”);
TestBroadcastReceiver receiver = new TestBroadcastReceiver();
registerReceiver(receiver, filter);


public class TestBroadcastReceiver extends Broadcast Receiver
{
  @Override
  public void onReceive(Context context, Intent intent)
  {
        (.................... do something here................)
    }
}
Broadcast Receivers
               register in app manifest
<receiver android:name=”CameraPressedReceiver”>
     <intent-filter>
           <action
           android:name=”android.intent.action.CAMERA_BUTTON”
        />
     </intent-filter>
</receiver>


 public class CameraPressed extends Broadcast Receiver
 {
   @Override
   public void onReceive(Context context, Intent intent)
   {
         (.................... do something here................)
     }
 }

More Related Content

What's hot

Android notification
Android notificationAndroid notification
Android notificationKrazy Koder
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android Aakash Ugale
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycleSoham Patel
 
Android activity
Android activityAndroid activity
Android activityKrazy Koder
 
UI controls in Android
UI controls in Android UI controls in Android
UI controls in Android DivyaKS12
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - IntentDaniela Da Cruz
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & viewsma-polimi
 
android layouts
android layoutsandroid layouts
android layoutsDeepa Rani
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in androidPrawesh Shrestha
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development pptsaitej15
 
Events and Listeners in Android
Events and Listeners in AndroidEvents and Listeners in Android
Events and Listeners in Androidma-polimi
 
Classes and Objects
Classes and Objects  Classes and Objects
Classes and Objects yndaravind
 

What's hot (20)

Android notification
Android notificationAndroid notification
Android notification
 
Android UI
Android UIAndroid UI
Android UI
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Android User Interface
Android User InterfaceAndroid User Interface
Android User Interface
 
Android activity
Android activityAndroid activity
Android activity
 
UI controls in Android
UI controls in Android UI controls in Android
UI controls in Android
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - Intent
 
Fragment
Fragment Fragment
Fragment
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
 
android layouts
android layoutsandroid layouts
android layouts
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Android Location and Maps
Android Location and MapsAndroid Location and Maps
Android Location and Maps
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
 
Events and Listeners in Android
Events and Listeners in AndroidEvents and Listeners in Android
Events and Listeners in Android
 
Broadcast receivers
Broadcast receiversBroadcast receivers
Broadcast receivers
 
Android intent
Android intentAndroid intent
Android intent
 
Activity lifecycle
Activity lifecycleActivity lifecycle
Activity lifecycle
 
Classes and Objects
Classes and Objects  Classes and Objects
Classes and Objects
 

Viewers also liked

Intent in android
Intent in androidIntent in android
Intent in androidDurai S
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAhsanul Karim
 
[Android] Intent and Activity
[Android] Intent and Activity[Android] Intent and Activity
[Android] Intent and ActivityNikmesoft Ltd
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android FragmentsSergi Martínez
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI WidgetsAhsanul Karim
 
Strategic intent
Strategic intentStrategic intent
Strategic intentwimmba
 
Menu in android
Menu in androidMenu in android
Menu in androidDurai S
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cyclemssaman
 
Day 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location APIDay 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location APIAhsanul Karim
 
Android GPS Tutorial
Android GPS TutorialAndroid GPS Tutorial
Android GPS TutorialAhsanul Karim
 
Android - Broadcast Receiver
Android - Broadcast ReceiverAndroid - Broadcast Receiver
Android - Broadcast ReceiverYong Heui Cho
 
Android tutorial ppt
Android tutorial pptAndroid tutorial ppt
Android tutorial pptRehna Renu
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application DevelopmentBenny Skogberg
 

Viewers also liked (20)

Intent in android
Intent in androidIntent in android
Intent in android
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
 
[Android] Intent and Activity
[Android] Intent and Activity[Android] Intent and Activity
[Android] Intent and Activity
 
Android Lesson 2
Android Lesson 2Android Lesson 2
Android Lesson 2
 
Android Services
Android ServicesAndroid Services
Android Services
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android Fragments
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Strategic intent
Strategic intentStrategic intent
Strategic intent
 
Strategic intent
Strategic intentStrategic intent
Strategic intent
 
Menu in android
Menu in androidMenu in android
Menu in android
 
Android ppt
Android ppt Android ppt
Android ppt
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cycle
 
The android activity lifecycle
The android activity lifecycleThe android activity lifecycle
The android activity lifecycle
 
Android adapters
Android adaptersAndroid adapters
Android adapters
 
Day 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location APIDay 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location API
 
Android GPS Tutorial
Android GPS TutorialAndroid GPS Tutorial
Android GPS Tutorial
 
Android - Broadcast Receiver
Android - Broadcast ReceiverAndroid - Broadcast Receiver
Android - Broadcast Receiver
 
Android tutorial ppt
Android tutorial pptAndroid tutorial ppt
Android tutorial ppt
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 

Similar to Android: Intent, Intent Filter, Broadcast Receivers

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
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in androidOum Saokosal
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
Android应用开发简介
Android应用开发简介Android应用开发简介
Android应用开发简介easychen
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basicsAnton Narusberg
 
An Introduction to Deep Linking and App Indexing Codelab
An Introduction to Deep Linking and App Indexing CodelabAn Introduction to Deep Linking and App Indexing Codelab
An Introduction to Deep Linking and App Indexing CodelabJarek Wilkiewicz
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversUtkarsh Mankad
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx34ShreyaChauhan
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010Skills Matter
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callmaamir farooq
 
android level 3
android level 3android level 3
android level 3DevMix
 
Android Security Essentials
Android Security EssentialsAndroid Security Essentials
Android Security EssentialsOSCON Byrum
 

Similar to Android: Intent, Intent Filter, Broadcast Receivers (20)

Introduction toandroid
Introduction toandroidIntroduction toandroid
Introduction toandroid
 
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
 
Intents are Awesome
Intents are AwesomeIntents are Awesome
Intents are Awesome
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in android
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Android应用开发简介
Android应用开发简介Android应用开发简介
Android应用开发简介
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
An Introduction to Deep Linking and App Indexing Codelab
An Introduction to Deep Linking and App Indexing CodelabAn Introduction to Deep Linking and App Indexing Codelab
An Introduction to Deep Linking and App Indexing Codelab
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
 
Android intents in android application-chapter7
Android intents in android application-chapter7Android intents in android application-chapter7
Android intents in android application-chapter7
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
 
Android開発の基礎_20101218
Android開発の基礎_20101218Android開発の基礎_20101218
Android開発の基礎_20101218
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone call
 
Android Froyo
Android FroyoAndroid Froyo
Android Froyo
 
android level 3
android level 3android level 3
android level 3
 
Android Security Essentials
Android Security EssentialsAndroid Security Essentials
Android Security Essentials
 

Recently uploaded

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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.pdfhans926745
 
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...Miguel Araújo
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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.pptxHampshireHUG
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
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 interpreternaman860154
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 MenDelhi Call girls
 
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 Scriptwesley chun
 
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 WorkerThousandEyes
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
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...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Android: Intent, Intent Filter, Broadcast Receivers

  • 1. Intents & Intent Filters codeandroid.org
  • 2. Intents & Intents Filter • Intents : request for an action to be performed (usually on a set of data) • Intent Filters : register Activities, Services, and Broadcast Receivers (as being capable of performing an action on a set of data) • Broadcast Receivers : listens to intents
  • 3. Intents • Support interaction between any application components available on an Android device • start a new Activity • broadcast messages (broadcast intents)
  • 4. Intents Starting a new Activity Intent intent = new Intent (......................); startActivity(intent);
  • 5. Intents Starting a new Activity Dial a number Intent intent = new Intent (Intent.ACTION_DIAL, Uri.parse(“tel:93675359”)); startActivity(intent); Launch a website Intent intent = new Intent (Intent.ACTION_VIEW, Uri.parse(“http://codeandroid.org”)); startActivity(intent);
  • 6. Intents Starting a new Activity Launch an Activity Intent intent = new Intent (this, HelloWorld.class); startActivity(intent); Launch an Activity Intent intent = new Intent (this, HelloWorld.class); intent.putExtra(“title”,”Hello codeandroid”); startActivity(intent);
  • 7. Intent Filters AndroidManifest.xml <activity android:name=”.HelloWorld” android:label=”@string/app_name”> <intent-filter> <action android:name=”android.intent.action.MAIN”/> <category android:name=”android.intent.category.LAUNCHER”/> </intent-filter> </activity> Launch Hello World Intent intent = new Intent (this, HelloWorld.class); startActivity(intent);
  • 8. Intent Filters • Required for Intent resolution to match Intents to Activities, Services, or BroadcastReceivers • Most Intent Filters are declared in AndroidManifest.xml of an application
  • 9. Intent Filters AndroidManifest.xml <activity android:name=”.HelloWorld” android:label=”@string/app_name”> <intent-filter> <action android:name=”org.codeandroid.intentstest.HelloWorld”/> <category android:name=”android.intent.category.DEFAULT”/> </intent-filter> </activity> Launch Hello World Intent intent = new Intent (“org.codeandroid.intentstest.HelloWorld”); startActivity(intent);
  • 10. Intent Filters AndroidManifest.xml <activity android:name=”.HelloWorld” android:label=”@string/app_name”> <intent-filter> <action android:name=”android.intent.action.VIEW”/> <category android:name=”android.intent.category.DEFAULT”/> <category android:name=”android.intent.category.BROWSABLE”/> <data android:scheme=”http” android:host=”androidium.org”/> </intent-filter> </activity> Launch Hello World Intent intent = new Intent (Intent.ACTION_VIEW, Uri.parse(“http://androidium.org”)); startActivity(intent);
  • 11. Intent Filters AndroidManifest.xml <activity android:name=”.HelloWorld” android:label=”@string/app_name”> <intent-filter> <action android:name=”android.intent.action.VIEW”/> <category android:name=”android.intent.category.DEFAULT”/> <category android:name=”android.intent.category.BROWSABLE”/> <data android:scheme=”http” android:host=”www.google.com” android:pathPrefix=”/advanced_search” /> </intent-filter> </activity>
  • 12. Intent Filters AndroidManifest.xml <activity android:name=”.HelloWorld” android:label=”@string/app_name”> <intent-filter> <action android:name=”android.intent.action.VIEW”/> <category android:name=”android.intent.category.DEFAULT”/> <category android:name=”android.intent.category.BROWSABLE”/> <data android:scheme=”codeandroid”/> </intent-filter> </activity> Launch Hello World Intent intent = new Intent (Intent.ACTION_VIEW, Uri.parse(“codeandroid://”)); startActivity(intent);
  • 13. Intents Launch the Android Market Uri marketUri = Uri.parse(“http://market.android.com/search?q=pname:com.buuuk.buUuk”) Intent intent = new Intent (Intent.ACTION_VIEW, marketUri); startActivity(intent); Uri marketUri = Uri.parse(“market://search?q=pname:com.buuuk.buUuk”) Intent intent = new Intent (Intent.ACTION_VIEW, marketUri); startActivity(intent);
  • 14. Intents Broadcast Intents • broadcast messages between components with the sendBroadcast method • makes an application more open, by broadcasting to current and other applications
  • 15. Intents Broadcast Intents Intent intent = new Intent(“org.codeandroid.intentstest.TestBroadcastReceiver”); sendBroadcast(intent);
  • 16. Broadcast Receivers • listen to Broadcast Intents • must be registered (either in code or within the app manifest • use Intent Filter to specify which Intents it is listening for
  • 17. Broadcast Receivers registered inside code IntentFilter filter = new IntentFilter(“org.codeandroid.intentstest.TestBroadcastReceiver”); TestBroadcastReceiver receiver = new TestBroadcastReceiver(); registerReceiver(receiver, filter); public class TestBroadcastReceiver extends Broadcast Receiver { @Override public void onReceive(Context context, Intent intent) { (.................... do something here................) } }
  • 18. Broadcast Receivers register in app manifest <receiver android:name=”CameraPressedReceiver”> <intent-filter> <action android:name=”android.intent.action.CAMERA_BUTTON” /> </intent-filter> </receiver> public class CameraPressed extends Broadcast Receiver { @Override public void onReceive(Context context, Intent intent) { (.................... do something here................) } }