SlideShare a Scribd company logo
1 of 12
Android Application Development
                        Broadcast Receiver


          Click to edit Master subtitle style




                                                             Ahsanul Karim
                                                ahsanul.karim@sentinelbd.com
                                                     Sentinel Solutions Ltd.
                                                   http://www.sentinelbd.com
5/21/11
Application Building Blocks
ly Corresponding to one screen.




     IntentReceiver Service          Activity      ContentProvider




ns or status changes.that runs in up your process. applications to share data.
       Faceless task Can wake the background.
                                           Enable




     5/21/11
Android Application Anatomy
                      Activities                                     Services
            1.    Provides User Interface                      1.   No User Interface
           2.    Usually represents a Single              2.      Runs in Background
                           Screen
                                                3.             Extends the Service Base
     3.         Can contain one/more Views                                Class
      4.         Extends the Activity Base
                           class
                            Application= Set of Android Components

      Intent/Broadcast Receiver                                 Content Provider
       1.    Receives and Reacts to                  1.        Makes application data
               broadcast Intents                             available to other apps
          2.  No UI but can start an            2.        Data stored in SQLite database
                     Activity                    3.        Extends the ContentProvider
                                                                    Base class
3.      Extends the BroadcastReceiver
     5/21/11       Base Class
Broadcast Receivers
1.   A broadcast receiver is a component that responds to system-wide
Broadcast announcements.
1.   Many broadcasts originate from the system—for example, a
Broadcast announcing that the screen has turned off, the battery
is low, or a picture was captured or an SMS is received.
1.   Applications can also initiate broadcasts—for example, to let other
Applications know that some data has been downloaded to the
device and is available for them to use.
1.   Although broadcast receivers don't display a user interface, they may
create a status bar notification to alert the user when a
broadcast event occurs.
1.   More commonly, though, a broadcast receiver is just a "gateway" to
other components and is intended to do a very minimal amount of
work. For instance, it might initiate a service/or start an activity to
perform some work based on the event.
      5/21/11
Android Application Anatomy


                      Activity 1             Activity 2

     UI



      Service                       BroadcastReceiver



           Intents
           1.   Directed Intents
           2.   Broadcast Intents                         OS

                   BIG PICTURE
 5/21/11
Broadcast Receivers
1. We’ll use a Broadcast Receiver to capture SMS receive event
2. We capture the SMS receive event and launch an Activity to show the sms and give user
an option to reply the SMS
                                                   Activity




                 OS                         BroadcastReceiver




     5/21/11
Broadcast Receivers
 1. Create a new project BroadcastReceiverDemo
 2. A broadcast receiver is implemented as a subclass of BroadcastReceiver and each
 broadcast is delivered as an Intent object. In this case the intent is detected by
 android.provider.Telephony.SMS_RECEIVED

 To do this we’ll create a class SMSReceiver that extends BroadcastReceiver class and
    define the method onReceive()




                                             BroadcastReceiver




      5/21/11
Broadcast Receivers (Contd.)
 3. We also need to add SMSReceiver as receiver of a particular Intent (SMS received)
 which is identified by android.provider.Telephony.SMS_RECEIVED




                                             BroadcastReceiver




  5/21/11
Broadcast Receivers (Contd.)
 4. Also we have to add permission for receiving SMS




                                             BroadcastReceiver




  5/21/11
Broadcast Receivers (Contd.)
 5. Now we run the application
 6. Now we use emulator control to send sms




  5/21/11
Sending SMS
  1. Add permission in menifest.xml



  2. We add the following code for sending SMS from anywhere of our application




  5/21/11
Exercise

 We’ll create a replica of SMS application of Android

 1.   Application will have a basic TabActivity with 3 tabs (Activities)
       1.  Send- will give user option to send sms (2 input fields for number and text)
 All sent SMS will be saved in database
       1.  Inbox- (List Activity) which will fetch all received SMS from database
       2.  Sent- (ListActivity) which will fetch all sent SMS
 1.   A broadcast receiver which will receive SMS and save them to database




      5/21/11

More Related Content

What's hot

Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversJagdish Gediya
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User InterfaceMarko Gargenta
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorialnirajsimulanis
 
What’s new in Xcode 8? – Future of Native App Development Opportunities
What’s new in Xcode 8? – Future of Native App Development OpportunitiesWhat’s new in Xcode 8? – Future of Native App Development Opportunities
What’s new in Xcode 8? – Future of Native App Development OpportunitiesRigel Networks LLC
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recieversUtkarsh Mankad
 
android level 1
android level 1android level 1
android level 1DevMix
 
Android architecture components
Android architecture components Android architecture components
Android architecture components azzeddine chenine
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cyclemssaman
 
Android Capstone Project, Final Deliverable Documentation
Android Capstone Project, Final Deliverable DocumentationAndroid Capstone Project, Final Deliverable Documentation
Android Capstone Project, Final Deliverable DocumentationNate Betz
 
Create your First Watchkit App
Create your First Watchkit AppCreate your First Watchkit App
Create your First Watchkit AppPawan Ramteke
 
MobileAppDev Handout#2
MobileAppDev Handout#2MobileAppDev Handout#2
MobileAppDev Handout#2trupti1976
 
Android notification
Android notificationAndroid notification
Android notificationKrazy Koder
 

What's hot (20)

Android 101
Android 101Android 101
Android 101
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Unit2
Unit2Unit2
Unit2
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User Interface
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorial
 
Mobile testing android
Mobile testing   androidMobile testing   android
Mobile testing android
 
What’s new in Xcode 8? – Future of Native App Development Opportunities
What’s new in Xcode 8? – Future of Native App Development OpportunitiesWhat’s new in Xcode 8? – Future of Native App Development Opportunities
What’s new in Xcode 8? – Future of Native App Development Opportunities
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recievers
 
android level 1
android level 1android level 1
android level 1
 
Android architecture components
Android architecture components Android architecture components
Android architecture components
 
Android session 2
Android session 2Android session 2
Android session 2
 
Google Android
Google AndroidGoogle Android
Google Android
 
Android session 1
Android session 1Android session 1
Android session 1
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cycle
 
Android session 3
Android session 3Android session 3
Android session 3
 
Android Capstone Project, Final Deliverable Documentation
Android Capstone Project, Final Deliverable DocumentationAndroid Capstone Project, Final Deliverable Documentation
Android Capstone Project, Final Deliverable Documentation
 
Create your First Watchkit App
Create your First Watchkit AppCreate your First Watchkit App
Create your First Watchkit App
 
MobileAppDev Handout#2
MobileAppDev Handout#2MobileAppDev Handout#2
MobileAppDev Handout#2
 
Android notification
Android notificationAndroid notification
Android notification
 

Viewers also liked

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
 
Action Bar Sherlock tutorial
Action Bar Sherlock tutorialAction Bar Sherlock tutorial
Action Bar Sherlock tutorialAhsanul Karim
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Ahsanul Karim
 
Day 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedDay 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedAhsanul Karim
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in BackgroundAhsanul Karim
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedAhsanul Karim
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesAhsanul Karim
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentAhsanul Karim
 
Lecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & PreferencesLecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & PreferencesAhsanul Karim
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIAhsanul Karim
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)Ahsanul Karim
 

Viewers also liked (16)

Mcq peresentation
Mcq  peresentationMcq  peresentation
Mcq peresentation
 
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
 
Action Bar Sherlock tutorial
Action Bar Sherlock tutorialAction Bar Sherlock tutorial
Action Bar Sherlock tutorial
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
Training android
Training androidTraining android
Training android
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
Day 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedDay 1 Android: Before Getting Started
Day 1 Android: Before Getting Started
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting Started
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
 
Lecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & PreferencesLecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & Preferences
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts API
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)
 
Client-Server
Client-ServerClient-Server
Client-Server
 
GCM for Android
GCM for AndroidGCM for Android
GCM for Android
 

Similar to Day 6: Android BroadcastReceiver Component

Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAhsanul Karim
 
Android broadcast receiver tutorial
Android broadcast receiver  tutorialAndroid broadcast receiver  tutorial
Android broadcast receiver tutorialmaamir farooq
 
Android broadcast receiver tutorial
Android broadcast receiver   tutorialAndroid broadcast receiver   tutorial
Android broadcast receiver tutorialmaamir farooq
 
Android : a linux-based mobile operating system
Android : a linux-based mobile operating systemAndroid : a linux-based mobile operating system
Android : a linux-based mobile operating systemClément Escoffier
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx34ShreyaChauhan
 
Beginning android
Beginning android Beginning android
Beginning android Igor R
 
Android application development
Android application developmentAndroid application development
Android application developmentMd. Mujahid Islam
 
Basic of Android App Development
Basic of Android App DevelopmentBasic of Android App Development
Basic of Android App DevelopmentAbhijeet Gupta
 
04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)TECOS
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications developmentAlfredo Morresi
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidjavalabsf
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principlesHenk Laracker
 

Similar to Day 6: Android BroadcastReceiver Component (20)

Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
 
Android broadcast receiver tutorial
Android broadcast receiver  tutorialAndroid broadcast receiver  tutorial
Android broadcast receiver tutorial
 
Android broadcast receiver tutorial
Android broadcast receiver   tutorialAndroid broadcast receiver   tutorial
Android broadcast receiver tutorial
 
Android : a linux-based mobile operating system
Android : a linux-based mobile operating systemAndroid : a linux-based mobile operating system
Android : a linux-based mobile operating system
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
Beginning android
Beginning android Beginning android
Beginning android
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android beginners David
Android beginners DavidAndroid beginners David
Android beginners David
 
Android platform
Android platform Android platform
Android platform
 
Basic of Android App Development
Basic of Android App DevelopmentBasic of Android App Development
Basic of Android App Development
 
Android Introduction by Kajal
Android Introduction by KajalAndroid Introduction by Kajal
Android Introduction by Kajal
 
04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications development
 
Android Basic- CMC
Android Basic- CMCAndroid Basic- CMC
Android Basic- CMC
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Aptech Apps
Aptech Apps Aptech Apps
Aptech Apps
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principles
 

More from Ahsanul Karim

লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsAhsanul Karim
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsAhsanul Karim
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycleAhsanul Karim
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI WidgetsAhsanul Karim
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesAhsanul Karim
 
Mobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete StudyMobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete StudyAhsanul Karim
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_startedAhsanul Karim
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Ahsanul Karim
 
Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Ahsanul Karim
 

More from Ahsanul Karim (11)

লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycle
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
 
Mobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete StudyMobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete Study
 
List Views
List ViewsList Views
List Views
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_started
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3
 
Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2
 

Recently uploaded

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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...
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
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
 

Day 6: Android BroadcastReceiver Component

  • 1. Android Application Development Broadcast Receiver Click to edit Master subtitle style Ahsanul Karim ahsanul.karim@sentinelbd.com Sentinel Solutions Ltd. http://www.sentinelbd.com 5/21/11
  • 2. Application Building Blocks ly Corresponding to one screen. IntentReceiver Service Activity ContentProvider ns or status changes.that runs in up your process. applications to share data. Faceless task Can wake the background. Enable 5/21/11
  • 3. Android Application Anatomy Activities Services 1. Provides User Interface 1. No User Interface 2. Usually represents a Single 2. Runs in Background Screen 3. Extends the Service Base 3. Can contain one/more Views Class 4. Extends the Activity Base class Application= Set of Android Components Intent/Broadcast Receiver Content Provider 1. Receives and Reacts to 1. Makes application data broadcast Intents available to other apps 2. No UI but can start an 2. Data stored in SQLite database Activity 3. Extends the ContentProvider Base class 3. Extends the BroadcastReceiver 5/21/11 Base Class
  • 4. Broadcast Receivers 1. A broadcast receiver is a component that responds to system-wide Broadcast announcements. 1. Many broadcasts originate from the system—for example, a Broadcast announcing that the screen has turned off, the battery is low, or a picture was captured or an SMS is received. 1. Applications can also initiate broadcasts—for example, to let other Applications know that some data has been downloaded to the device and is available for them to use. 1. Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs. 1. More commonly, though, a broadcast receiver is just a "gateway" to other components and is intended to do a very minimal amount of work. For instance, it might initiate a service/or start an activity to perform some work based on the event. 5/21/11
  • 5. Android Application Anatomy Activity 1 Activity 2 UI Service BroadcastReceiver Intents 1. Directed Intents 2. Broadcast Intents OS BIG PICTURE 5/21/11
  • 6. Broadcast Receivers 1. We’ll use a Broadcast Receiver to capture SMS receive event 2. We capture the SMS receive event and launch an Activity to show the sms and give user an option to reply the SMS Activity OS BroadcastReceiver 5/21/11
  • 7. Broadcast Receivers 1. Create a new project BroadcastReceiverDemo 2. A broadcast receiver is implemented as a subclass of BroadcastReceiver and each broadcast is delivered as an Intent object. In this case the intent is detected by android.provider.Telephony.SMS_RECEIVED To do this we’ll create a class SMSReceiver that extends BroadcastReceiver class and define the method onReceive() BroadcastReceiver 5/21/11
  • 8. Broadcast Receivers (Contd.) 3. We also need to add SMSReceiver as receiver of a particular Intent (SMS received) which is identified by android.provider.Telephony.SMS_RECEIVED BroadcastReceiver 5/21/11
  • 9. Broadcast Receivers (Contd.) 4. Also we have to add permission for receiving SMS BroadcastReceiver 5/21/11
  • 10. Broadcast Receivers (Contd.) 5. Now we run the application 6. Now we use emulator control to send sms 5/21/11
  • 11. Sending SMS 1. Add permission in menifest.xml 2. We add the following code for sending SMS from anywhere of our application 5/21/11
  • 12. Exercise We’ll create a replica of SMS application of Android 1. Application will have a basic TabActivity with 3 tabs (Activities) 1. Send- will give user option to send sms (2 input fields for number and text) All sent SMS will be saved in database 1. Inbox- (List Activity) which will fetch all received SMS from database 2. Sent- (ListActivity) which will fetch all sent SMS 1. A broadcast receiver which will receive SMS and save them to database 5/21/11