• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Day 6: Android BroadcastReceiver Component
 

Day 6: Android BroadcastReceiver Component

on

  • 6,777 views

BroadcastReceiver in Android:

BroadcastReceiver in Android:
1. How to respond to Intent broadcast
2. How to intercept incoming SMS
3. How to put an application in device startup

Statistics

Views

Total Views
6,777
Views on SlideShare
1,732
Embed Views
5,045

Actions

Likes
0
Downloads
93
Comments
0

4 Embeds 5,045

http://droidtraining.wordpress.com 4989
http://droidtraining.wordpress.com. 49
http://webcache.googleusercontent.com 4
https://droidtraining.wordpress.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Day 6: Android BroadcastReceiver Component Day 6: Android BroadcastReceiver Component Presentation Transcript

    • Android Application Development Broadcast Receiver Click to edit Master subtitle style Ahsanul Karim ahsanul.karim@sentinelbd.com Sentinel Solutions Ltd. http://www.sentinelbd.com5/21/11
    • Application Building Blocksly Corresponding to one screen. IntentReceiver Service Activity ContentProviderns 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 class3. Extends the BroadcastReceiver 5/21/11 Base Class
    • Broadcast Receivers1. A broadcast receiver is a component that responds to system-wideBroadcast announcements.1. Many broadcasts originate from the system—for example, aBroadcast announcing that the screen has turned off, the batteryis low, or a picture was captured or an SMS is received.1. Applications can also initiate broadcasts—for example, to let otherApplications know that some data has been downloaded to thedevice and is available for them to use.1. Although broadcast receivers dont display a user interface, they maycreate a status bar notification to alert the user when abroadcast event occurs.1. More commonly, though, a broadcast receiver is just a "gateway" toother components and is intended to do a very minimal amount ofwork. For instance, it might initiate a service/or start an activity toperform 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 Receivers1. We’ll use a Broadcast Receiver to capture SMS receive event2. We capture the SMS receive event and launch an Activity to show the sms and give useran 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