The Broadcast Class Registration Broadcast Processing

Similar documents
LECTURE 12 BROADCAST RECEIVERS

Services Broadcast Receivers Permissions

Services. service: A background task used by an app.

Safety First - Android sicher programmieren! Benjamin Reimold & Stephan Linzner

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

CS378 -Mobile Computing. Services and Broadcast Receivers

Mobile and Ubiquitous Computing: Android Programming (part 4)

The Intent Class Starting Activities with Intents. Explicit Activation Implicit Activation via Intent resolution

SHWETANK KUMAR GUPTA Only For Education Purpose

ANDROID TRAINING PROGRAM COURSE CONTENT

Multiple Activities. Many apps have multiple activities

The Intent Class Starting Activities with Intents. Explicit Activation Implicit Activation via Intent resolution

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Mobile Computing. Introduction to Android

Basic UI elements: Defining Activity UI in the code. Marco Ronchetti Università degli Studi di Trento

Android User Interface

Android Ecosystem and. Revised v4presenter. What s New

Android User Interface Android Smartphone Programming. Outline University of Freiburg

Use the API or contact customer service to provide us with the following: General ios Android App Name (friendly one-word name)

Answers to Exercises

MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR

Android permissions Defining and using permissions Component permissions and related APIs

Lecture 2 Android SDK

Mobile Programming Practice Background processing AsynTask Service Broadcast receiver Lab #5

Mobile Application Development Android

ATC Android Application Development

Android Application Development Course Code: AND-401 Version 7 Duration: 05 days

Security Philosophy. Humans have difficulty understanding risk

CS 403X Mobile and Ubiquitous Computing Lecture 5: Web Services, Broadcast Receivers, Tracking Location, SQLite Databases Emmanuel Agu

Android Services. Victor Matos Cleveland State University. Services

Android Services & Local IPC: The Command Processor Pattern (Part 1)

BITalino Java Application Programming Interface. Documentation Android API

Android Application Development

ANDROID DEVELOPMENT. Course Details

Intents & Intent Filters. codeandroid.org

Lecture 08. Android Permissions Demystified. Adrienne Porter Felt, Erika Chin, Steve Hanna, Dawn Song, David Wagner. Operating Systems Practical

OFFLINE MODE OF ANDROID

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

Scippa: System-Centric IPC Provenance on Android

Outline. Admin. Example: TipCalc. Android: Event Handler Blocking, Android Inter-Thread, Process Communications. Recap: Android UI App Basic Concepts

Why using intents. Activity. Screen1 Screen 2

COLLEGE OF ENGINEERING, NASHIK-4

Course Learning Outcomes (CLO): Student Outcomes (SO):

Application Fundamentals

Chapter 5 Defining the Manifest

App Development for Smart Devices. Lec #7: Windows Azure

Intents and Intent Filters

Podstawowe komponenty aplikacji, wymiana międzyprocesowa

32. And this is an example on how to retrieve the messages received through NFC.

Mobile Application Development Android

Android Programming Lecture 7 9/23/2011

RUNTIME PERMISSIONS IN ANDROID 6.0 Lecture 10a

ANDROID SYLLABUS. Advanced Android

Android Application Development

Introduction to Android

CS378 -Mobile Computing. Intents

Understanding Application

Questions and Answers. Q.1) Which of the following is the most ^aeuroeresource hungry ^aeuroepart of dealing with activities on android?

CSCU9YH Development with Android

Instructions on Yealink s SDK for Yealink T5 Smart Business Phone Series. Instructions on Yealink s SDK for Yealink T5 Smart Business Phone Series

Broadcast receivers. Marco Ronchetti Università degli Studi di Trento

NQuire300. Customer Information Terminal SDK Handbook

A Tour of Android. and some of it s APIs. Bryan Noll

Instructions on Yealink s SDK for Yealink T5 Smart Media Phone Series. Instructions on Yealink s SDK for Yealink T5 Smart Media Phone Series

Android Security Lab WS 2013/14 Lab 2: Android Permission System

Writing Efficient Drive Apps for Android. Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations

Lab 5 Periodic Task Scheduling

Android framework. How to use it and extend it

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Mobile Application Development Android

Writing Zippy Android Apps

CS378 -Mobile Computing. Anatomy of and Android App and the App Lifecycle

Java Training Center - Android Application Development

Spring Lecture 5 Lecturer: Omid Jafarinezhad

Efficient Android Threading

Android Programming Lecture 8: Activities, Odds & Ends, Two New Views 9/28/2011

Overview of Patterns

Services are software components designed specifically to perform long background operations.

Ariadnima - Android Component Flow Reconstruction and Visualization

Android-Basics. Praktikum Mobile und Verteilte Systeme

Programming with Android: Intents. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Software Engineering Large Practical: Accessing remote data and XML parsing. Stephen Gilmore School of Informatics October 8, 2017

Android Programming - Jelly Bean

Introduction to Android Multimedia

An Android Application for Remote Ringer

Android-Basics. Praktikum Mobile und Verteilte Systeme. Prof. Dr. Claudia Linnhoff-Popien André Ebert, Sebastian Feld

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II)

AN4375 Application note

1. Implementation of Inheritance with objects, methods. 2. Implementing Interface in a simple java class. 3. To create java class with polymorphism

Android App Development

Services. Background operating component without a visual interface Running in the background indefinitely

ANDROID NATIVE APP: INTRODUCTION TO ANDROID. Roberto Beraldi

Android AND-401. Android Application Development. Download Full Version :

App Development for Android. Prabhaker Matet

Introduction to Android Development

Minds-on: Android. Session 2

The Open Mobile Provisioning API

Services & Interprocess Communication (IPC) CS 282 Principles of Operating Systems II Systems Programming for Android

Wirtschaftsinformatik Skiseminar ao. Prof. Dr. Rony G. Flatscher. Seminar paper presentation Dennis Robert Stöhr

Transcription:

The Broadcast Class Registration Broadcast Processing

Base class for components that receive and react to events

BroadcastReceivers register to receive events in which they are interested

When Events occur they are represented as Intents Those Intents are then broadcast to the system

Android routes the Intents to BroadcastReceivers that have registered to receive them BroadcastReceivers receive the Intent via a call to onreceive()

Register BroadcastReceivers Broadcast an Intent Android delivers Intent to registered recipients by calling their onreceive() method Event handled in onreceive()

BroadcastReceivers can register in two ways Statically, in AndroidManifest.XML Dynamically, by calling a registerreceiver() method

Put <receiver> and <intent-filter> tags in AndroidManifest.xml

<receiver android:enabled=["true" "false"] android:exported=["true" "false"] android:icon="drawable resource" android:label="string resource" android:name="string" android:permission="string" android:process="string" >... </receiver>

Specify <intent-filter> tag within the <receiver>

Receivers are registered with the system at boot time or when their application package is added at runtime

Create an IntentFilter Create a BroadcastReceiver Register BroadcastReceiver using registerreceiver() LocalBroadcastManager Context As necessary, call unregisterreceiver() to unregister BroadcastReceiver

Several broadcast methods supported Normal vs. Ordered Normal: processing order undefined Ordered: sequential processing in priority order Sticky vs. Non-Sticky Sticky: Store Intent after initial broadcast Non-Sticky: Discard Intent after initial broadcast With or without receiver permissions

Log extra Intent resolution information Intent.setFlag(FLAG_DEBUG_LOG_RESOLUTION) List registered BroadcastReceivers Dynamically registered % adb shell dumpsys activity b Statically registered % adb shell dumpsys package

Intents delivered by calling onreceive(), passing in: the Context in which the receiver is running the Intent that was broadcast

Hosting process has high priority while onreceive() is executing

onreceive() runs on the main Thread, so it should be short-lived If event handling is lengthy, consider starting a Service, rather than performing complete operation in onreceive()

Receiver is not considered valid once onreceive() returns Normally BroadcastReceivers can t start asynchronous operations e.g., showing a dialog, starting an Activity via startactivityforresult() Can use goasync() to keep BroadcastReceiver alive

// send Intent to BroadcastReceivers in priority order void sendorderedbroadcast (Intent intent, # String receiverpermission) // send Intent to BroadcastReceivers in priority order // includes multiple parameters for greater control void sendorderedbroadcast (Intent intent, # String receiverpermission, # BroadcastReceiver resultreceiver, Handler scheduler, # int initialcode, # String initialdata, # Bundle initialextras)

Sticky Intents are cached by Android New Intents overwrite older Intents they match When BroadcastReceivers are dynamically registered Cached sticky Intents matching the specified IntentFilter are broadcast to the BroadcastReceiver One matching sticky Intent is returned to the caller

//public abstract class Context // send sticky Intent to interested BroadcastReceivers void sendstickybroadcast (Intent intent) // send sticky Intent to interested BroadcastReceivers in priority order // sender can provide various parameters for greater control void sendstickyorderedbroadcast (Intent intent, # BroadcastReceiver resultreceiver,# Handler scheduler, # int initialcode, # String initialdata, # Bundle initialextras) Broadcaster must have BROADCAST_STICKY permission to send sticky Intents

Threads, AsyncTasks & Handlers