COMP 365 Android Development.  Perform operations in the background  Services do not have a user interface (UI)  Can run without appearing on screen.

Slides:



Advertisements
Similar presentations
Services. Application component No user interface Two main uses Performing background processing Supporting remote method execution.
Advertisements

Programming with Android: Notifications, Threads, Services
Application Fundamentals Android Development. Announcements Posting in D2L Tutorials.
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.
Chapter 6 Jam! Implementing Audio in Android Apps.
Chapter 6: Jam! Implementing Audio in Android Apps.
CSS216 MOBILE PROGRAMMING Android, Chapter 3 Book: “Professional Android™ 2 Application Development” by Reto Meier, 2010 by: Andrey Bogdanchikov (
The Android Activity Lifecycle. Slide 2 Introduction Working with the Android logging system Rotation and multiple layouts Understanding the Android activity.
Lec 06 AsyncTask Local Services IntentService Broadcast Receivers.
Applet class The Applet class provides the essential framework that enables applets to be run by a web browser Applet do not have main method Applet depend.
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.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Content Providers & Services.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton.
Rajab Davudov. Agenda Eclipse, ADT and Android SDK APK file Fundamentals – Activity – Service – Content Provider – Broadcast Receiver – Intent Hello World.
Using Intents to Broadcast Events Intents Can be used to broadcast messages anonymously Between components via the sendBroadcast method As a result Broadcast.
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
Mobile Application Development using Android Lecture 2.
DUE Hello World on the Android Platform.
CS378 - Mobile Computing Intents.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
Activities and Intents. Activities Activity is a window that contains the user interface of your application,typically an application has one or more.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Recitation.
10/10/2015 E.R.Edwards 10/10/2015 Staffordshire University School of Computing Introduction to Android Overview of Android System Android Components Component.
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.
ANDROID L. Grewe Components  Java Standard Development Kit (JDK) (download) (latest version)  AndroidStudio.
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.
Services 1 CS440. What is a Service?  Component that runs on background  Context.startService(), asks the system to schedule work for the service, to.
Mobile Programming Midterm Review
DKU-MUST Mobile ICT Education Center 10. Activity and Intent.
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.
Technische Universität München Services, IPC and RPC Gökhan Yilmaz, Benedikt Brück.
Lecture 6: Process and Threads Topics: Process, Threads, Worker Thread, Async Task Date: Mar 1, 2016.
Speech Service & client(Activity) 오지영.
Android intro Building UI #1: interactions. AndroidManifest.xml permissions 2.
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.
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
Lecture 2: Android Concepts
Broadcast receivers.
CS371m - Mobile Computing Services and Broadcast Receivers
Lecture 2 Zablon Ochomo Android Programming Lecture 2 Zablon Ochomo
Lecture 7: Service Topics: Services, Playing Media.
Instructor: Mazhar Hussain
Lecture 7: Android Services
MAD.
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 Application Development android.cs.uchicago.edu
Developing Android Services
Application Fundamentals
Android Developer Fundamentals V2 Lesson 5
Service Services.
Lecture 7: Service Topics: Services, Broadcast Receiver, Playing Media.
Lecture 2: Android Concepts
Mobile Programming Dr. Mohsin Ali Memon.
CIS 470 Mobile App Development
Mobile Programming Broadcast Receivers.
Presentation transcript:

COMP 365 Android Development

 Perform operations in the background  Services do not have a user interface (UI)  Can run without appearing on screen  Promotes multitasking, as multiple activities can be conducted while services run

 A component can also interact with a service to perform interprocess communication (IPC)  A service might download information for an activity, perform file input/output (I/O), or play music entirely from the background

 A service can take two forms:  Started  Bound

 When an activity or other application component starts a service using startService(), it is considered to be started and can run in the background indefinitely even if the component that started it is stopped. These services usually perform one function and stop themselves.

 A service is considered to be bound when an application component binds it using bindService(). This allows a client-server interaction between the service and the application component, but once the application bound to the service ends, the service is destroyed.

 In order to create a service you must extend the Service class or a subclass of the Service class. You will need to override the following abstract classes:  onStartCommand()  onBind()  onCreate()  onDestroy()

 Android calls this method when the service is started using the startService() method and the service will run indefinitely until stopped with the stopSelf() or the stopService() methods.

 This method is called when an application component asks to be bound to the service by calling bindService(). If you choose to let your service be bound to an application component, it must be have an interface that returns an IBinder.

 onCreate() - Called when the service is first created.  onDestroy() - Called when the service is being destroyed.

......

 To create a service, you can extend either the Service or the IntentService class.  The IntentService class has many advantages as it creates default functionality for required methods like onStartCommand(), onHandleIntent(), stopSelf(), and onBind().

 There are two kinds of broadcasts:  Normal broadcasts (sent using Context.sendBroadcast) are asynchronous; meaning that broadcasts are run and delivered in an undefined order.  Ordered broadcasts (sent using Context.sendOrderedBroadcast) which means broadcasts are sent one at a time.

 You can dynamically register an instance of this classs with Context.registerReceiver() or statically publish an implementation through the tag in your manifest file  only valid for the duration of the call to onReceive (Context, Intent), after that Broacast Receivers are no longer considered active

public class MyBroadcastReceiver extends BroadcastReciever public void onReceive (Context context, Intent intent) { //TODO Auto-generated method stub //Extract data included in the Intent CharSequence intentData = intent.getCharSequenceExtra(“message”); Toast.makeText(content, “Received the global broadcast message: “+intentData,Toast.LENGTH_LONG).show(); }

//name of Android program //name of the intent