Technische Universität München Services, IPC and RPC Gökhan Yilmaz, Benedikt Brück.

Slides:



Advertisements
Similar presentations
Programming with Android: Activities and Intents
Advertisements

1 Working with the Bluetooth radio Nilanjan Banerjee Mobile Systems Programming University of Arkansas Fayetteville, AR
Services. Application component No user interface Two main uses Performing background processing Supporting remote method execution.
Programming with Android: Activities and Intents Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
Programming with Android: Activities and Intents Luca Bedogni Marco Di Felice Dipartimento di Informatica – Scienza e Ingegneria Università di Bologna.
Cosc 5/4730 Android Services. What is a service? From android developer web pages: Most confusion about the Service class actually revolves around what.
CSE2102 Introduction to Software Engineering Lab 2 Sept/4/2013.
Programming with Android: Activities
Android 02: Activities David Meredith
Lec 06 AsyncTask Local Services IntentService Broadcast Receivers.
Manifest File, Intents, and Multiple Activities. Manifest File.
The Activity Class 1.  One application component type  Provides a visual interface for a single screen  Typically supports one thing a user can do,
@2011 Mihail L. Sichitiu1 Android Introduction Application Fundamentals.
Bluetooth. Bluetooth is an open, wireless protocol for exchanging data between devices over a short distance. –managed by the Bluetooth Special Interest.
1 Android: Event Handler Blocking, Android Inter-Thread, Process Communications 10/11/2012 Y. Richard Yang.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Content Providers & Services.
Rajab Davudov. Agenda Eclipse, ADT and Android SDK APK file Fundamentals – Activity – Service – Content Provider – Broadcast Receiver – Intent Hello World.
COMP 365 Android Development.  Perform operations in the background  Services do not have a user interface (UI)  Can run without appearing on screen.
DUE Hello World on the Android Platform.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Recitation.
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
COMP 365 Android Development.  Every android application has a manifest file called AndroidManifest.xml  Found in the Project folder  Contains critical.
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
Linking Activities using Intents How to navigate between Android Activities 1Linking Activities using Intents.
Working in the Background Radan Ganchev Astea Solutions.
Android 13: Services and Content Providers Kirk Scott 1.
Services A Service is an application component that can perform long-running operations in the background and does not provide a user interface. An application.
Activity Android Club Agenda Hello Android application Application components Activity StartActivity.
Mobile Programming Midterm Review
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Creating multiple views Introduction to intents Passing data to.
Introducing Intents Intents Bind application components and navigate between them Transform device into collection of interconnected systems Creating a.
Intents 1 CS440. Intents  Message passing mechanism  Most common uses:  starting an Activity (open an , contact, etc.)  starting an Activity.
Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Android Programming Steve Ko Computer Sciences and Engineering University at Buffalo.
Conway’s Game Of Live 1 Fall 2014 CS7020: Game Design and Development.
Lecture 2: Android Concepts
Activities and Intents Chapter 3 1. Objectives Explore an activity’s lifecycle Learn about saving and restoring an activity Understand intents and how.
Intents and Broadcast Receivers Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
Services. What is a Service? A Service is not a separate process. A Service is not a thread. A Service itself is actually very simple, providing two main.
The Ingredients of Android Applications. A simple application in a process In a classical programming environment, the OS would load the program code.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Putting together the AndroidManifest.xml file Creating multiple.
Developing Android Services. Objectives Creating a service that runs in background Performing long-running tasks in a separate thread Performing repeated.
CS371m - Mobile Computing Intents 1. Allow us to use applications and components that are already part of Android System – start activities – start services.
Introduction to Android Programming
Intents and Broadcast Receivers
Lecture 2: Android Concepts
Programming with Android:
CS371m - Mobile Computing Services and Broadcast Receivers
Linking Activities using Intents
Instructor: Mazhar Hussain
Lecture 7: Android Services
Android Mobile Application Development
Reactive Android Development
Android Application Development android.cs.uchicago.edu
Developing Android Services
Application Fundamentals
Activities and Intents
Objects First with Java
Service Services.
Activities and Intents
It is used to Start an Activity Start a Service Deliver a Broadcast
Application Fundamentals
Lecture 2: Android Concepts
Objects First with Java
Chapter 5 Your Second Activity.
CIS 470 Mobile App Development
Presentation transcript:

Technische Universität München Services, IPC and RPC Gökhan Yilmaz, Benedikt Brück

Technische Universität München Services Is an application component Can perform long-running operations in the background Does not provide a user interface Can be started by another application component (e.g. Activity or Service) Possibility of binding to a service an perform IPC Do not necessarily run in own thread or process But runs even in background PR App - Gökhan Yilmaz, Benedikt Brück2

Technische Universität München Services Has to define an own Thread, when tasks takes longer than five seconds Simple way: Use “IntentService” Create subclass of “IntentService” override onHandleIntent(android.content.Intent), put workload there Superclass creates a separate thread and performs lifecycle operations More complicated way: “use Service” itself Starting component has to call startService in both ways PR App - Gökhan Yilmaz, Benedikt Brück3

Technische Universität München Services Create subclass of “Service” Override four main functions: onCreate() onStartCommand(android.content.Intent, int, int) onBind(android.content.Intent) onDestroy() Declare in manifest More attributes like permission can be found in android developers guide PR App - Gökhan Yilmaz, Benedikt Brück4

Technische Universität München Services onCreate() Is called when service is first created Should contain one-time setup procedures onStartCommand(android.content.Intent, int, int) Is called, when another component (e.g. Activity) calls startService(android.content.Intent) If service is not bound, stopSelf() or stopService(…) has to be called Intent is used for IPC, for flags see Android Developer Guide) Returns constant (e.g START_STICKY, see Android Developer Guide) onBind(android.content.Intent) Is called, when another component calls bindService(..) (see RPC) onDestroy() Is called on destruction Should contain clean-up PR App - Gökhan Yilmaz, Benedikt Brück5

Technische Universität München IPC Means Inter-Process-Communication Way for exchanging data among multiple processes Processes can be Services, Activities, … Two Types of IPC exist in Android Intent based IPC RPC PR App - Gökhan Yilmaz, Benedikt Brück6

Technische Universität München Intent Based IPC Data can be passed in both directions using Intent objects Enables a convenient, high-level system of inter-process communication. Intent objects are passed from process to process, using methods such as startActivity and startActivityForResult To receive data the Activity should have implemented onActivityResult to receive the result PR App - Gökhan Yilmaz, Benedikt Brück7

Technische Universität München Intent Based IPC PutExtra and getExtra methods are defined to provide general purpose IPC in Intent Intent data can only be sent at the start of a component (startActivity, startService) or be received at the end (onActivityResult) During process execution broadcasts must be used PR App - Gökhan Yilmaz, Benedikt Brück8

Technische Universität München Example of Intent Based IPC (send data to another activity via Intent) void returnResult(String greeting) { // Create the Intent object Intent i = new Intent(); // Put an extra named "result" in the intent i.putextra("result", greeting); // Make this Intent the result for this activity setResult(RESULT_OK, i); // End this activity finish(); } PR App - Gökhan Yilmaz, Benedikt Brück9

Technische Universität München Examples of Intent Based IPC to receive the data protected void onActivityResult(int requestCode, int resultCode, Intent result) { if (resultCode == RESULT_OK) { String greeting = result.getStringExtra("result"); someTextview.setText(greeting); } PR App - Gökhan Yilmaz, Benedikt Brück10