SlideShare una empresa de Scribd logo
1 de 36
Mobile Application
Development
Instructor:
Muhammad Jameel
Lecturer
Muhammad.jameel@superior.edu.pk
Explicit Intents
Intents, Android Basic Building blocks, Activities, Services, Broadcast Receivers, Intents, Types
of Intents, Explicit Intents, Implicit Intents, Basic Example of Explicit Intents in Android
Intents
• Intent means many different meaning in different situations.
• So in this lecture I will show, What intents are, what they do, and how they
do.
There’re four building blocks in Android
• Activities
• Services.
• Broadcast Receivers.
• Intent.
Activities
• Something with which user interacts, something the user sees
on the screen.
Farrukh Ehsan – Superior University Lahore -
farrukh.ehsan@superior.edu.pk
Services
Something that runs in the background, but it runs on the main thread.
These are used to perform the long tasks, like downloading a file,
connecting to a mail service, connecting to a server, uploading a file to a
drop box and stuff like that.
All these thing happens in services.
User can’t see them, but they started by activities and such operations run
independently. Even if your activity is off your services may run in the
background.
Broadcast Receivers
These are functions who sleeps all the time, but when suddenly something
happens, they wake up and they do something.
For example if your battery gets low, and you have broadcast receiver
inside your app who wakes up and shut down all the downloads.
So that’s what broadcast receivers do. These are a kind a alarms that you
want ring when a specific event triggered.
Intent
• It is a kind of messenger that response to messages.
What an intent does?
• It is used to start a new activity from where ever you are. It is like going to a different page
in html from one page.
• If you want to download something your download services begin in the background in
case you’re downloading a big file, or you want to play music in the background, so intents
are used to start all these services.
• The third thing that intents are used register the broadcast receivers.
• Intents are also used to tell the system, which is the entry point of your application inside
of your application, and which activity should appear in launcher screen, or inside the list
of application installed on your android OS.
Types of Intents
1. Explicit Intents
2. Implicit Intents
Explicit Intents
• Explicit intents are those intents, when you know the activity
you are calling.
Implicit Intents
• Implicit intents, when you don’t know who to call.
• You know you need to send a SMS, or you need to send an
Email, when know the functionality but you don’t know, who is
going to do that function for you, that’s when an intent will
become implicit intent.
Basic Example – Explicit Intents
First Activity - MainActivity
Second Activity – ActB
String File – strings.xml
Lecture
Implicit Intents, Different Pieces of Implicit Intents, Android Package Manger, Intent
Resolution
Implicit Intents
• Implicit Intents just define the functionality and let the Android OS to decide the right
activity for that functionality.
• With the implicit intents, you just tell the action you want to perform without worrying
about who will perform that action.
• You get a notification when something happens in your phone.
• For example before making a call, your airplane mode is ON or your battery level gets low.
• So whenever there is an event and an intent is created out of that event, it
will be supplied to everybody.
• Suppose you’ve a broadcast receiver, who is actively listening to such
events, then that broadcast receiver is going to be connected.
• There are hundreds of event in Android device that converted into an
intent object, and that intent broadcast to everybody in the Android OS.
There are four pieces of an Intent
1. Action
2. Data
3. Extras
4. Categories
Action
• Here you define, what you want to do. For example you want to
place a phone call, you want to send an SMS etc.
Data
• What type of the data you want to work with.
• For example URI, images or whatever type of data you are
working with.
•
Extras
• What additional information you want to provide.
• For example, you want to application to place a phone call, but who you
want to call, what is phone number of that particular person you want to
call.
• In the extra you provide additional information needed to perform the
task.
Categories
• Categories are nothing more than group of components which are used to
handle the intents.
• For example if you remember from the first lecture, in all your activities
inside your application, you have something called category launcher, that
how your activity appears in the list of apps in the launcher.
Who do you call?
• Basically there are three things that works with intent.
• You want to call somebody either it can be activities, or it can services or
it can broadcast receivers.
• Now remember activities and services comes one category, and
broadcast receivers come under separate category.
• You can call any one of them using an intent object, there are different
methods are used to start these three things such as start activity.
Android Package Manager
• It is the part of Android OS, who is responsible for the handling the intents
in the Android.
• When a Package Manager receives an intent request, its going to check
which applications are running, which are applications are nothing
running.
• Android Package Manager is responsible for deciding which component is
best suited to handle your intent.
What is an Intent Filter?
• Whenever you want to handle the implicit intent you have to declare the
intent filters.
• Intent filters are simply advertisers. They say for action, category, data a
particular activity, service or broadcast receiver can handle.
Intent Filter - Example 1/2
• For example you have your activity A, and you want to send an Email.
• So what you are going to do? You are going to create an intent that has some
action, category and data.
• On the other hand you have your email activity B, where it define an intent
filter to define what type of data, action, and category it can handle.
• Now your Package Manager accept the intent which is sent, it compares the
action, data and category requested by the first activity with the action, data and
category define inside the intent filter of the other activity B.
• And if they match, then that activity B is called. That’s how your email activity
will be called through implicit intent.
Example 2/2
You send an intent that intent gets compared with the intent filter
on the receiving side. If it matches then that activity, service or
broadcast receiver gets called, otherwise nothing will happen.
• So an intent filter describe what ACTION, DATA, and
CATEGORIES that component can handle.
• Mostly intent filter defined inside the manifest file, but may also
be dynamically register in the code.
• Next you define what intents can be handled by that component.
• In the next step you write that code which you want to be
executed when an intent is called.
Package Manager with activities and Services
• When you install an activity, you are going to define an intent filter to the
Android Package Manager, it will read your intent filter, and after checking
it will define what ACTION, DATA and CATEGORIES your activity can
handle.
• This happens for every application you install on your Android OS.
• How many activities or services an app have?, what intents can be handled
by each Activity or Service, this data is handled by the Android Package
Manager.
Intent resolution
• The whole process of receiving an intent request and then
starting the suited activity or service for that intent is called
intent resolution.
• This complete process is monitor and managed by the Android
Package Manager.
• This process is only used for Activities and Services.
Quiz_02:
Q_01
What the purpose for using explicit intent explain with example?
Q_02
Why implicit intent different from explicit intent explain with
example?

Más contenido relacionado

Similar a W5_Lec09_Lec10_Intents.pptx

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_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
 
Application Software in Computer and Services.pptx
Application Software in Computer and Services.pptxApplication Software in Computer and Services.pptx
Application Software in Computer and Services.pptx
JessaBejer1
 
Android_Workshop
Android_WorkshopAndroid_Workshop
Android_Workshop
Senthil ACS
 
Software Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good ArchitectureSoftware Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good Architecture
mahmud05
 

Similar a W5_Lec09_Lec10_Intents.pptx (20)

android development training in mumbai
android development training in mumbaiandroid development training in mumbai
android development training in mumbai
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development Tutorial
 
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 intent
Android intentAndroid intent
Android intent
 
Mobile testing
Mobile testingMobile testing
Mobile testing
 
Mobile Application Guideline | Mobile App Development Company
Mobile Application Guideline | Mobile App Development Company Mobile Application Guideline | Mobile App Development Company
Mobile Application Guideline | Mobile App Development Company
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in android
 
05: The 5 App Metrics That Are Crucial To Your App's Success
05: The 5 App Metrics That Are Crucial To Your App's Success05: The 5 App Metrics That Are Crucial To Your App's Success
05: The 5 App Metrics That Are Crucial To Your App's Success
 
Kotlin for Android App Development Presentation
Kotlin for Android App Development PresentationKotlin for Android App Development Presentation
Kotlin for Android App Development Presentation
 
Mobile testing android
Mobile testing   androidMobile testing   android
Mobile testing android
 
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
 
Lecture 3 - Misuse Cases Final.ppt
Lecture 3 - Misuse Cases Final.pptLecture 3 - Misuse Cases Final.ppt
Lecture 3 - Misuse Cases Final.ppt
 
Application Software in Computer and Services.pptx
Application Software in Computer and Services.pptxApplication Software in Computer and Services.pptx
Application Software in Computer and Services.pptx
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
unit3.pptx
unit3.pptxunit3.pptx
unit3.pptx
 
Android_Workshop
Android_WorkshopAndroid_Workshop
Android_Workshop
 
Software Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good ArchitectureSoftware Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good Architecture
 
Location sharing and automatic message sender Android Application
Location sharing and automatic message sender Android ApplicationLocation sharing and automatic message sender Android Application
Location sharing and automatic message sender Android Application
 
Intents are Awesome
Intents are AwesomeIntents are Awesome
Intents are Awesome
 

Último

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Cara Menggugurkan Kandungan 087776558899
 

Último (8)

Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s Tools
 
Thane 💋 Call Girls 7738631006 💋 Call Girls in Thane Escort service book now. ...
Thane 💋 Call Girls 7738631006 💋 Call Girls in Thane Escort service book now. ...Thane 💋 Call Girls 7738631006 💋 Call Girls in Thane Escort service book now. ...
Thane 💋 Call Girls 7738631006 💋 Call Girls in Thane Escort service book now. ...
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
Leading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdfLeading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdf
 
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 

W5_Lec09_Lec10_Intents.pptx

  • 2. Explicit Intents Intents, Android Basic Building blocks, Activities, Services, Broadcast Receivers, Intents, Types of Intents, Explicit Intents, Implicit Intents, Basic Example of Explicit Intents in Android
  • 3. Intents • Intent means many different meaning in different situations. • So in this lecture I will show, What intents are, what they do, and how they do.
  • 4. There’re four building blocks in Android • Activities • Services. • Broadcast Receivers. • Intent.
  • 5. Activities • Something with which user interacts, something the user sees on the screen. Farrukh Ehsan – Superior University Lahore - farrukh.ehsan@superior.edu.pk
  • 6. Services Something that runs in the background, but it runs on the main thread. These are used to perform the long tasks, like downloading a file, connecting to a mail service, connecting to a server, uploading a file to a drop box and stuff like that. All these thing happens in services. User can’t see them, but they started by activities and such operations run independently. Even if your activity is off your services may run in the background.
  • 7. Broadcast Receivers These are functions who sleeps all the time, but when suddenly something happens, they wake up and they do something. For example if your battery gets low, and you have broadcast receiver inside your app who wakes up and shut down all the downloads. So that’s what broadcast receivers do. These are a kind a alarms that you want ring when a specific event triggered.
  • 8. Intent • It is a kind of messenger that response to messages.
  • 9. What an intent does? • It is used to start a new activity from where ever you are. It is like going to a different page in html from one page. • If you want to download something your download services begin in the background in case you’re downloading a big file, or you want to play music in the background, so intents are used to start all these services. • The third thing that intents are used register the broadcast receivers. • Intents are also used to tell the system, which is the entry point of your application inside of your application, and which activity should appear in launcher screen, or inside the list of application installed on your android OS.
  • 10. Types of Intents 1. Explicit Intents 2. Implicit Intents
  • 11. Explicit Intents • Explicit intents are those intents, when you know the activity you are calling.
  • 12. Implicit Intents • Implicit intents, when you don’t know who to call. • You know you need to send a SMS, or you need to send an Email, when know the functionality but you don’t know, who is going to do that function for you, that’s when an intent will become implicit intent.
  • 13. Basic Example – Explicit Intents
  • 14. First Activity - MainActivity
  • 16. String File – strings.xml
  • 17. Lecture Implicit Intents, Different Pieces of Implicit Intents, Android Package Manger, Intent Resolution
  • 18. Implicit Intents • Implicit Intents just define the functionality and let the Android OS to decide the right activity for that functionality. • With the implicit intents, you just tell the action you want to perform without worrying about who will perform that action.
  • 19. • You get a notification when something happens in your phone. • For example before making a call, your airplane mode is ON or your battery level gets low.
  • 20. • So whenever there is an event and an intent is created out of that event, it will be supplied to everybody. • Suppose you’ve a broadcast receiver, who is actively listening to such events, then that broadcast receiver is going to be connected. • There are hundreds of event in Android device that converted into an intent object, and that intent broadcast to everybody in the Android OS.
  • 21. There are four pieces of an Intent 1. Action 2. Data 3. Extras 4. Categories
  • 22. Action • Here you define, what you want to do. For example you want to place a phone call, you want to send an SMS etc.
  • 23. Data • What type of the data you want to work with. • For example URI, images or whatever type of data you are working with. •
  • 24. Extras • What additional information you want to provide. • For example, you want to application to place a phone call, but who you want to call, what is phone number of that particular person you want to call. • In the extra you provide additional information needed to perform the task.
  • 25. Categories • Categories are nothing more than group of components which are used to handle the intents. • For example if you remember from the first lecture, in all your activities inside your application, you have something called category launcher, that how your activity appears in the list of apps in the launcher.
  • 26. Who do you call? • Basically there are three things that works with intent. • You want to call somebody either it can be activities, or it can services or it can broadcast receivers. • Now remember activities and services comes one category, and broadcast receivers come under separate category. • You can call any one of them using an intent object, there are different methods are used to start these three things such as start activity.
  • 27. Android Package Manager • It is the part of Android OS, who is responsible for the handling the intents in the Android. • When a Package Manager receives an intent request, its going to check which applications are running, which are applications are nothing running. • Android Package Manager is responsible for deciding which component is best suited to handle your intent.
  • 28. What is an Intent Filter? • Whenever you want to handle the implicit intent you have to declare the intent filters. • Intent filters are simply advertisers. They say for action, category, data a particular activity, service or broadcast receiver can handle.
  • 29. Intent Filter - Example 1/2 • For example you have your activity A, and you want to send an Email. • So what you are going to do? You are going to create an intent that has some action, category and data. • On the other hand you have your email activity B, where it define an intent filter to define what type of data, action, and category it can handle. • Now your Package Manager accept the intent which is sent, it compares the action, data and category requested by the first activity with the action, data and category define inside the intent filter of the other activity B. • And if they match, then that activity B is called. That’s how your email activity will be called through implicit intent.
  • 31. You send an intent that intent gets compared with the intent filter on the receiving side. If it matches then that activity, service or broadcast receiver gets called, otherwise nothing will happen.
  • 32. • So an intent filter describe what ACTION, DATA, and CATEGORIES that component can handle. • Mostly intent filter defined inside the manifest file, but may also be dynamically register in the code. • Next you define what intents can be handled by that component. • In the next step you write that code which you want to be executed when an intent is called.
  • 33. Package Manager with activities and Services • When you install an activity, you are going to define an intent filter to the Android Package Manager, it will read your intent filter, and after checking it will define what ACTION, DATA and CATEGORIES your activity can handle. • This happens for every application you install on your Android OS. • How many activities or services an app have?, what intents can be handled by each Activity or Service, this data is handled by the Android Package Manager.
  • 34.
  • 35. Intent resolution • The whole process of receiving an intent request and then starting the suited activity or service for that intent is called intent resolution. • This complete process is monitor and managed by the Android Package Manager. • This process is only used for Activities and Services.
  • 36. Quiz_02: Q_01 What the purpose for using explicit intent explain with example? Q_02 Why implicit intent different from explicit intent explain with example?