SlideShare a Scribd company logo
1 of 17
ANDROID SERVICES
AND
BROADCAST RECEIVERS
- Presented By –
Mrs. N. G. Mandlik
Assistant Professor,
Department of Computer Studies,
CSIBER, Kolhapur
BROADCAST & BROADCAST RECEIVERS
• Broadcast is the system-wide events that can occur when the device starts,
when a message is received on the device or when incoming calls are received,
or when a device goes to airplane mode, etc.
• Broadcast Receivers are used to respond to these system-wide events.
• Broadcast Receiver is one of the core component of Android application.
• Broadcast Receivers simply respond to broadcast messages from other
applications or from the system itself.
• These messages are sometime called events or intents.
• Android system sends broadcasts when system events occur such as system
boots up, device starts charging, connectivity changing, low battery etc.
• Some apps can also send custom broadcasts to notify other apps like- data
download completed.
• Unlike Activities, Broadcast Receivers does not have User Interface.
WHAT ARE BROADCAST RECEIVERS?
• There are mainly two types of Broadcast Receivers:
• Static Broadcast Receivers: These types of Receivers are declared in the manifest
file and works even if the app is closed.
• Dynamic Broadcast Receivers: These types of receivers work only if the app is active
or minimized.
SYSTEM-GENERATED BROADCASTS
• Some of the important and system-generated intents are-
Intents Description
android.intent.action.BATTERY_CHANGED This keeps track of the battery’s charging state,
percentage, and other information about the
battery.
android.intent.action.BATTERY_LOW It indicates the low battery condition.
android.intent.action.POWER_CONNECTED It indicates that the power is connected to the
device.
android.intent.action.POWER_DISCONNECTE
D
The power is disconnected from the device.
android.intent.action.BOOT_COMPLETED This broadcast is shown only once when the device
boots for the first time.
android.intent.action.CALL This intent is to perform a call to some specific
person, according to data.
SYSTEM-GENERATED INTENTS
• Some of the important and system-generated intents are-
Intents Description
android.intent.action.DATE_CHANGED This means the date of the device has changed.
android.intent.action.REBOOT This means that the device has rebooted.
android.intent.action.CONNECTIVITY_CHANG
E
This shows the network connectivity of the device
has changed.
android.intent.action.BUG_REPORT This reports the bugs if there is any.
android.intent.action.CALL_BUTTON The user pressed the call button to make a call,
which takes them to an appropriate user interface.
IMPLEMENTING BROADCAST RECEIVERS IN
ANDROID
• To implement a receiver, it need to be register first, which could be done
in the following two ways:
1. Context-registered
• This is also known as the dynamically registering method.
• In this, the registration is done using Context.registerReceiver() method.
• Implementation of Context-registered receiver:
IntentFilter filter = new IntentFilter();
intentFilter.addAction(getPackageName()+"android.net.conn.CO
NNECTIVITY_CHANGE");
MyReceiver myReceiver = new MyReceiver();
registerReceiver(myReceiver, filter);
IMPLEMENTING BROADCAST RECEIVERS IN
ANDROID
2. Manifest-registered
• This is also known as the statistically registering method.
• In this, the registration is done in the manifest file, using <receiver> tag.
• Implementation of Manifest-registered receiver:
<receiver android:name="DataFlairReceiver" >
<intent-filter>
<action
android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
INTENT & INTENT-FILTERS
IN ANDROID
• The intent is a messaging object which tells what kind of action to be performed. It facilitates
the communication between the components.
• Intents are used to start an activity, start a service and deliver a broadcast.
• Two types of intents are-
• Explicit Intent : In explicit intent user knows about all the things like after clicking a button
which activity will start and Explicit intents are used for communication inside the application
• Implicit Intent : Implicit intents do not name a specific component like explicit intent, instead
declare general action to perform, which allows a component from another app to handle.
• Eg. when you tap the share button in any app you can see the Gmail, Bluetooth, and other
sharing app options.
INTENT & INTENT-FILTERS
IN ANDROID
• Intent Filters are expressions in the Manifest file of an Android Application which
decide the behavior of an intent.
• It is used to specify the type of intents that an Activity, service or Broadcast
receiver can respond to.
• It declares the functionality of its parent component (i.e. activity, services or
broadcast receiver).
• Intent filters mentioned in the Manifest file can be nested with the application
components and the type of intents can be specified to accept using these three
elements- action, category and data.
INTENT & INTENT-FILTERS
IN ANDROID
• Elements in Intent Filters-
• 1. Action: It represent an activities action, what an activity is going to do. It is declared
with the name attribute as given below-
• <action android:name = "string" />
• An Intent Filter element must contain one or more action element. Action is a string that
specifies the action to perform. You can declare your own action as given below. But we
usually use action constants defined by Intent class.
<intent-filter>
<action android:name="com.example.intentfilters.Main2Activity"/>
</intent-filter>
• For Example – Some of the common actions for starting an activity are ACTION_VIEW,
ACTION_SEND, ACTION_MAIN, ACTION_WEB_SEARCH etc.
INTENT & INTENT-FILTERS
IN ANDROID
• Elements in Intent Filters-
• 2. Category: This attribute of Intent filter dictates the behavior or nature of an Intent.
• There is a string which contains some additional information about the intent which will be
handled by a component.
• The syntax of category is as follows:
<category android:name="string" />
• Example of the common categories are-
• BROWSABLE - Browsable category, activity allows itself to be opened with web browser to
open the reference link provided in data.
• LAUNCHER - Launcher category puts an activity on the top of stack, whenever application
will start, the activity containing this category will be opened first.
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
INTENT & INTENT-FILTERS
IN ANDROID
• Elements in Intent Filters-
• 3. Data: There are two forms in which data can be passed, using URI(Uniform Resource
Identifiers) or MIME type of data.
The code of Intent Filter is used inside AndroidManifest.xml file for an
activity.
THANK YOU

More Related Content

Similar to Android Broadcast Receivers and System Events

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 Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development TutorialGermán Bringas
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Dr. Ramkumar Lakshminarayanan
 
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.pdfAbdullahMunir32
 
Android core components.pptx
Android core components.pptxAndroid core components.pptx
Android core components.pptxAdarshNair65
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycleKumar
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptBirukMarkos
 
Security on android
Security on androidSecurity on android
Security on androidpk464312
 
Advance Android application development workshop day 3
Advance Android application development workshop day 3Advance Android application development workshop day 3
Advance Android application development workshop day 3cresco
 
COVERT app
COVERT appCOVERT app
COVERT appitba9
 
Android security
Android securityAndroid security
Android securityKrazy Koder
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recieversUtkarsh Mankad
 

Similar to Android Broadcast Receivers and System Events (20)

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 Security
Android SecurityAndroid Security
Android Security
 
Android session 2
Android session 2Android session 2
Android session 2
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development Tutorial
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3
 
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
 
Android core components.pptx
Android core components.pptxAndroid core components.pptx
Android core components.pptx
 
Android Insights - 1 [Intents]
Android Insights - 1 [Intents]Android Insights - 1 [Intents]
Android Insights - 1 [Intents]
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
 
Unit2
Unit2Unit2
Unit2
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).ppt
 
Android intents in android application-chapter7
Android intents in android application-chapter7Android intents in android application-chapter7
Android intents in android application-chapter7
 
Security on android
Security on androidSecurity on android
Security on android
 
Mobile testing android
Mobile testing   androidMobile testing   android
Mobile testing android
 
Advance Android application development workshop day 3
Advance Android application development workshop day 3Advance Android application development workshop day 3
Advance Android application development workshop day 3
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
COVERT app
COVERT appCOVERT app
COVERT app
 
Android security
Android securityAndroid security
Android security
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recievers
 

More from VaishnaviGaikwad67

More from VaishnaviGaikwad67 (6)

reearch-presentation.pptx
reearch-presentation.pptxreearch-presentation.pptx
reearch-presentation.pptx
 
computer.pptx
computer.pptxcomputer.pptx
computer.pptx
 
Seaborn visualization.pptx
Seaborn visualization.pptxSeaborn visualization.pptx
Seaborn visualization.pptx
 
classification.pptx
classification.pptxclassification.pptx
classification.pptx
 
Unit - IV (1).pptx
Unit - IV (1).pptxUnit - IV (1).pptx
Unit - IV (1).pptx
 
Unit - IV.pptx
Unit - IV.pptxUnit - IV.pptx
Unit - IV.pptx
 

Recently uploaded

Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 

Recently uploaded (20)

Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 

Android Broadcast Receivers and System Events

  • 1. ANDROID SERVICES AND BROADCAST RECEIVERS - Presented By – Mrs. N. G. Mandlik Assistant Professor, Department of Computer Studies, CSIBER, Kolhapur
  • 2. BROADCAST & BROADCAST RECEIVERS • Broadcast is the system-wide events that can occur when the device starts, when a message is received on the device or when incoming calls are received, or when a device goes to airplane mode, etc. • Broadcast Receivers are used to respond to these system-wide events.
  • 3. • Broadcast Receiver is one of the core component of Android application. • Broadcast Receivers simply respond to broadcast messages from other applications or from the system itself. • These messages are sometime called events or intents. • Android system sends broadcasts when system events occur such as system boots up, device starts charging, connectivity changing, low battery etc. • Some apps can also send custom broadcasts to notify other apps like- data download completed. • Unlike Activities, Broadcast Receivers does not have User Interface. WHAT ARE BROADCAST RECEIVERS?
  • 4. • There are mainly two types of Broadcast Receivers: • Static Broadcast Receivers: These types of Receivers are declared in the manifest file and works even if the app is closed. • Dynamic Broadcast Receivers: These types of receivers work only if the app is active or minimized.
  • 5.
  • 6. SYSTEM-GENERATED BROADCASTS • Some of the important and system-generated intents are- Intents Description android.intent.action.BATTERY_CHANGED This keeps track of the battery’s charging state, percentage, and other information about the battery. android.intent.action.BATTERY_LOW It indicates the low battery condition. android.intent.action.POWER_CONNECTED It indicates that the power is connected to the device. android.intent.action.POWER_DISCONNECTE D The power is disconnected from the device. android.intent.action.BOOT_COMPLETED This broadcast is shown only once when the device boots for the first time. android.intent.action.CALL This intent is to perform a call to some specific person, according to data.
  • 7. SYSTEM-GENERATED INTENTS • Some of the important and system-generated intents are- Intents Description android.intent.action.DATE_CHANGED This means the date of the device has changed. android.intent.action.REBOOT This means that the device has rebooted. android.intent.action.CONNECTIVITY_CHANG E This shows the network connectivity of the device has changed. android.intent.action.BUG_REPORT This reports the bugs if there is any. android.intent.action.CALL_BUTTON The user pressed the call button to make a call, which takes them to an appropriate user interface.
  • 8. IMPLEMENTING BROADCAST RECEIVERS IN ANDROID • To implement a receiver, it need to be register first, which could be done in the following two ways: 1. Context-registered • This is also known as the dynamically registering method. • In this, the registration is done using Context.registerReceiver() method. • Implementation of Context-registered receiver: IntentFilter filter = new IntentFilter(); intentFilter.addAction(getPackageName()+"android.net.conn.CO NNECTIVITY_CHANGE"); MyReceiver myReceiver = new MyReceiver(); registerReceiver(myReceiver, filter);
  • 9. IMPLEMENTING BROADCAST RECEIVERS IN ANDROID 2. Manifest-registered • This is also known as the statistically registering method. • In this, the registration is done in the manifest file, using <receiver> tag. • Implementation of Manifest-registered receiver: <receiver android:name="DataFlairReceiver" > <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver>
  • 10. INTENT & INTENT-FILTERS IN ANDROID • The intent is a messaging object which tells what kind of action to be performed. It facilitates the communication between the components. • Intents are used to start an activity, start a service and deliver a broadcast. • Two types of intents are- • Explicit Intent : In explicit intent user knows about all the things like after clicking a button which activity will start and Explicit intents are used for communication inside the application • Implicit Intent : Implicit intents do not name a specific component like explicit intent, instead declare general action to perform, which allows a component from another app to handle. • Eg. when you tap the share button in any app you can see the Gmail, Bluetooth, and other sharing app options.
  • 11. INTENT & INTENT-FILTERS IN ANDROID • Intent Filters are expressions in the Manifest file of an Android Application which decide the behavior of an intent. • It is used to specify the type of intents that an Activity, service or Broadcast receiver can respond to. • It declares the functionality of its parent component (i.e. activity, services or broadcast receiver). • Intent filters mentioned in the Manifest file can be nested with the application components and the type of intents can be specified to accept using these three elements- action, category and data.
  • 12. INTENT & INTENT-FILTERS IN ANDROID • Elements in Intent Filters- • 1. Action: It represent an activities action, what an activity is going to do. It is declared with the name attribute as given below- • <action android:name = "string" /> • An Intent Filter element must contain one or more action element. Action is a string that specifies the action to perform. You can declare your own action as given below. But we usually use action constants defined by Intent class. <intent-filter> <action android:name="com.example.intentfilters.Main2Activity"/> </intent-filter> • For Example – Some of the common actions for starting an activity are ACTION_VIEW, ACTION_SEND, ACTION_MAIN, ACTION_WEB_SEARCH etc.
  • 13. INTENT & INTENT-FILTERS IN ANDROID • Elements in Intent Filters- • 2. Category: This attribute of Intent filter dictates the behavior or nature of an Intent. • There is a string which contains some additional information about the intent which will be handled by a component. • The syntax of category is as follows: <category android:name="string" /> • Example of the common categories are- • BROWSABLE - Browsable category, activity allows itself to be opened with web browser to open the reference link provided in data. • LAUNCHER - Launcher category puts an activity on the top of stack, whenever application will start, the activity containing this category will be opened first.
  • 15. INTENT & INTENT-FILTERS IN ANDROID • Elements in Intent Filters- • 3. Data: There are two forms in which data can be passed, using URI(Uniform Resource Identifiers) or MIME type of data.
  • 16. The code of Intent Filter is used inside AndroidManifest.xml file for an activity.