Using Intents to Broadcast Events Intents Can be used to broadcast messages anonymously Between components via the sendBroadcast method As a result Broadcast.

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 6 Overview Programming Tutorial 3: Sending/Receiving SMS Messages.
Advertisements

WiFi in Android.
Cosc 5/4730 Android Services. What is a service? From android developer web pages: Most confusion about the Service class actually revolves around what.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
Lec 06 AsyncTask Local Services IntentService Broadcast Receivers.
BroadcastReceiver.  Base class for components that receive and react to events  Events are represented as Intent objects  Intents received as parameter.
Cosc 5/4730 Android SMS. A note first Depending on the API level, an import changes because of a deprecated API 3 uses – import android.telephony.gsm.SmsManager;
Mobile Programming Pertemuan 6 Presented by Mulyono Poltek NSC Surabaya.
SMS. Short Message Service – Primarily text messages between mobile phones – First one sent December 3, 1982 “Merry Christmas” – In 2008 Approximately.
@2011 Mihail L. Sichitiu1 Android Introduction Application Fundamentals.
Emerging Platform#4: Android Bina Ramamurthy.  Android is an Operating system.  Android is an emerging platform for mobile devices.  Initially developed.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
CS378 - Mobile Computing Connecting Devices. How to pass data between devices? – Chat – Games – Driving Options: – Use the cloud and a service such as.
박 종 혁 컴퓨터 보안 및 운영체제 연구실 MobiSys '11 Proceedings of the 9th international conference on Mobile systems, applications,
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton.
Mobile Computing Lecture#08 IntentFilters & BroadcastReceivers.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Google Cloud Messaging for Android (GCM) is a free service that helps developers send data from servers to their Android.
Broadcast Receiver Android Club Agenda Broadcast Receiver Widget.
Broadcast intents.
P2P communication Using the GTalk Service API. Introduction Peer-to-Peer communication highly used in mobile devices. Very efficient to when certain factors.
Cosc 5/4730 Introduction: Threads, Android Activities, and MVC.
Integrating with Android Services. Introduction  Android has numerous built-in functionality that can be called from within your applications  SMS/MMS.
Cosc 5/4730 Broadcast Receiver. Broadcast receiver A broadcast receiver (short receiver) – is an Android component which allows you to register for system.
Android ICC Part II Inter-component communication.
COMP 365 Android Development.  Perform operations in the background  Services do not have a user interface (UI)  Can run without appearing on screen.
Mobile Application Development using Android Lecture 2.
Erika Chin Adrienne Porter Felt Kate Greenwood David Wagner University of California Berkeley MobiSys 2011.
DUE Hello World on the Android Platform.
CS378 - Mobile Computing Intents.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Cosc 5/4730 Android App Widgets. App Widgets App Widgets are miniature application views that can be embedded in other applications (such as the Home.
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
Android - Broadcast Receivers
Android Boot Camp for Developers Using Java, 3E
COMP 365 Android Development.  Every android application has a manifest file called AndroidManifest.xml  Found in the Project folder  Contains critical.
Telephony and sms API’S. Objective Telephony ➤ Initiating phone calls ➤ Reading the phone, network, data connectivity, and SIM states ➤ Monitoring changes.
DKU-MUST Mobile ICT Education Center 10. Activity and Intent.
Introducing Intents Intents Bind application components and navigate between them Transform device into collection of interconnected systems Creating a.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android.
Lecture 2: Android Concepts
Speech Service & client(Activity) 오지영.
Intents and Broadcast Receivers Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
CHAPTER 6 Threads, Handlers, and Programmatic Movement.
David Sutton SMS TELEPHONY IN ANDROID. OUTLINE  This week’s exercise, an SMS Pub Quiz  Simulating telephony on an emulator  Broadcast Intents and broadcast.
Event Driven (Asynchronous) Programming. Event handling in Unity Subclass a class that contains event handling methods, and then override those methods.
Messaging and Networking. Objectives Send SMS messages using the Messaging app Send SMS messages programmatically from within your app Receive and consume.
Intents and Broadcast Receivers
Lecture 2: Android Concepts
CS499 – Mobile Application Development
Broadcast receivers.
CS371m - Mobile Computing Services and Broadcast Receivers
Instructor: Mazhar Hussain
Android Runtime – Dalvik VM
Messaging Unit-4.
Activities and Intents
Android Mobile Application Development
Reactive Android Development
Broadcast Receivers A Android Component where you can register for system or application events, receive and react to broadcast intent. Each broadcast.
Android Programming Lecture 9
C# Event Processing Model
Application Fundamentals
Android Developer Fundamentals V2 Lesson 5
Emerging Platform#3 Android & Programming an App
Lecture 2: Android Concepts
Mobile Programming Dr. Mohsin Ali Memon.
Mobile Programming Broadcast Receivers.
Presentation transcript:

Using Intents to Broadcast Events Intents Can be used to broadcast messages anonymously Between components via the sendBroadcast method As a result Broadcast Receivers can be used To listen for and respond to these Broadcast Intents Android uses Broadcast Intents To broadcast system events Such as changes in network connectivity and incoming calls

Programmatically Registering a Broadcast Receiver For a receiver to receive broadcasts It must be registered either in code or within the application manifest To create a new Broadcast Receiver Extend the BroadcastReceiver class and Override the onReceive event handler To register the BroadcastReceiver object Use the registerReceiver method To unregister the BroadcastReceiver object Use the unregisterReceiver method

Registering a Broadcast Receiver in the manifest file In the case of applications including manifest Receivers The applications don’t have to be running When the Intent is broadcast for those receivers to execute To include a Broadcast Receiver in the manifest Add a receiver Tag within the application node

Assigning Priorities to Broadcast Receivers When sending a broadcast using the sendBroadcast() All the broadcast receivers that match the specified action Are called in random fashion What if you want to assign a particular order to receivers? In this case, you need to assign a priority to broadcast receivers The setPriority() method Takes priority values between 0 and 1000  The larger the number, the higher priority is To set the priority of receivers in the manifest file:

Assigning Priorities to Broadcast Receivers (Cont’d) To send a broadcast That is delivered to receivers with high priority first You should use sendOrderedBroadcast() When a broadcast receiver of higher priority Receives the broadcast will be passed to next receiver To handle the broadcast and Stop the broadcast from propagating to next receiver Use the abortBroadcast()

Auto-Launching Your App at Boot Time If you need to automatically start your app Whenever the device starts up, you need a receiver That responds to Boot Completed broadcasts To auto-launch an app during boot-up Add a new class to your package and derive it from The BroadcastRecevier base class In this way, when the device boots up It will fire your broadcast receiver calling onReceive method