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

Size: px
Start display at page:

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

Transcription

1 1 Mobile Programming Practice Background processing AsynTask Service Broadcast receiver Lab #5 Prof. Hwansoo Han T.A. Sung-in Hong T.A. Minseop Jeong

2 2 Background processing Every Android app has a main thread handling UI, coordinating user interactions, and receiving lifecycle events. If there is too much work happening on this thread, the app appears to hang or slow down, leading to an undesirable user experience. Any long-running computations and operations such as decoding a bitmap, accessing the disk, or performing network requests should be done on a separate background thread. In general, anything that takes more than a few milliseconds should be delegated to a background thread. Some of these tasks may be required to be performed while the user is actively interacting with the app.

3 3 AsyncTask This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers Should ideally be used for short operations (a few seconds) If you need to keep threads running for long periods of time, it is highly recommended you use Executor, ThreadPoolExecutor, and FutureTask provided by java.util.concurrent

4 4 AsyncTask A task can be cancelled at any time by invoking cancel(boolean) Does not be cancelled when an activity is destroyed Executed AsyncTask is an object Cannot be reuse Executed only once Only one AsyncTask can be run at a time

5 5 AsyncTask workflow

6 6 The 4 steps onpreexecute() invoked on the UI thread before the task is executed This step is normally used to setup the task, for instance by showing a progress bar in the user interface doinbackground(params...) invoked on the background thread immediately after onpreexecute() finishes executing This step is used to perform background computation that can take a long time. The parameters of the asynchronous task are passed to this step

7 7 The 4 steps onprogressupdate(progress...) invoked on the UI thread after a call to publishprogress(progress...) The timing of the execution is undefined This method is used to display any form of progress in the user interface while the background computation is still executing onpostexecute(result) invoked on the UI thread after the background computation finishes The result of the background computation is passed to this step as a parameter

8 8 AsyncTask s generic types Params the type of the parameters sent to the task upon execution Progress the type of the progress units published during the background computation Result the type of the result of the background computation

9 9 Usage AsyncTask<Params, Progress, Result> private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> { protected Long doinbackground(url... urls) { int count = urls.length; long totalsize = 0; for (int i = 0; i < count; i++) { totalsize += Downloader.downloadFile(urls[i]); publishprogress((int) ((i / (float) count) * 100)); // Escape early if cancel() is called if (iscancelled()) break; return totalsize; protected void onprogressupdate(integer... progress) { setprogresspercent(progress[0]); protected void onpostexecute(long result) { showdialog("downloaded " + result + " bytes");

10 10 Example of AsyncTask import android.os.asynctask; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.widget.textview; import android.widget.toast; import java.lang.ref.weakreference; public class MainActivity extends AppCompatActivity protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); AsyncTask<Integer,Double,String> cnttask = new CntTask(this); cnttask.execute(10); private static class CntTask extends AsyncTask<Integer,Double,String> { private final WeakReference<MainActivity> weakactivity; private CntTask(MainActivity mcontext) { this.weakactivity = new protected void onpreexecute() { super.onpreexecute(); Toast.makeText(weakActivity.get(), "Start AsyncTask", Toast.LENGTH_SHORT).show();

11 11 Example of AsyncTask(cont protected String doinbackground(integer... params) { for (int i=1; i<=params[0]; i++) { try { Thread.sleep(1000); publishprogress((double) (i)); // Escape early if cancel() is called if(iscancelled()) break; catch(interruptedexception e){ e.printstacktrace(); return protected void onprogressupdate(double... values) { super.onprogressupdate(values); TextView tv = weakactivity.get().findviewbyid(r.id.cnt); protected void onpostexecute(string s) { super.onpostexecute(s); Toast.makeText(weakActivity.get(),"End AsyncTask", Toast.LENGTH_SHORT).show();

12 12 Service An application component that can perform longrunning operations in the background, and it doesn't provide a user interface. Another application component can start a service, and it continues to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform inter-process communication (IPC). For example, a service can handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.

13 13 Three types of services Foreground performs some operation that is noticeable to the user. For example, an audio app would use a foreground service to play an audio track. must display a Notification. continues running even when the user isn't interacting with the app. Background performs an operation that isn't directly noticed by the user. For example, if an app used a service to compact its storage, that would usually be a background service.

14 14 Three types of services Bound A service is bound when an application component binds to it by calling bindservice(). A bound service offers a client-server interface that allows components to interact with the service, send requests, receive results, and even do so across processes with inter-process communication (IPC). A bound service runs only as long as another application component is bound to it. Multiple components can bind to the service at once, but when all of them unbind, the service is destroyed.

15 15 Choosing between a service and a thread A service is simply a component that can run in the background, even when the user is not interacting with your application, so you should create a service only if that is what you need If you must perform work outside of your main thread, but only while the user is interacting with your application, you should instead create a new thread Remember that if you do use a service, it still runs in your application's main thread by default, so you should still create a new thread within the service if it performs intensive or blocking operations.

16 Service workflow * 16

17 17 Service classes Service Base class for all services Use application s main thread by default IntentService Subclass of service Create a worker thread to handle all of the start request, one at a time

18 18 Callback methods of service onstartcommand() The system invokes this method by calling startservice() when another component (such as an activity) requests that the service be started When this method executes, the service is started and can run in the background indefinitely If you implement this, it is your responsibility to stop the service when its work is complete by calling stopself() or stopservice() If you only want to provide binding, you don't need to implement this method. onbind() The system invokes this method by calling bindservice() when another component wants to bind with the service (such as to perform RPC) In your implementation of this method, you must provide an interface that clients use to communicate with the service by returning an IBinder You must always implement this method; however, if you don't want to allow binding, you should return null

19 19 Callback methods of service oncreate() The system invokes this method to perform one-time setup procedures when the service is initially created (before it calls either onstartcommand() or onbind() ) If the service is already running, this method is not called. ondestroy() The system invokes this method when the service is no longer used and is being destroyed Your service should implement this to clean up any resources such as threads, registered listeners, or receivers This is the last call that the service receives.

20 20 Declaring a service in the manifest You must declare all services in your application's manifest file, just as you do for activities and other components To declare your service, add a <service> element as a child of the <application> element <manifest... >... <application... > <service android:name=".exampleservice" />... </application> </manifest>

21 21 Example of IntentService public class HelloIntentService extends IntentService { /** A constructor is required, and must call the super * constructor with a name for the worker thread. */ public HelloIntentService() { super("hellointentservice"); /** The IntentService calls this method from the default worker thread with * the intent that started the service. When this method returns, IntentService * stops the service, as protected void onhandleintent(intent intent) { // Normally we would do some work here, like download a file. // For our sample, we just sleep for 5 seconds. try { Thread.sleep(5000); catch (InterruptedException e) { // Restore interrupt status. Thread.currentThread().interrupt();

22 22 Example of service public class HelloService extends Service { private Looper servicelooper; private ServiceHandler servicehandler; private final class ServiceHandler extends Handler { public ServiceHandler(Looper looper) { public void handlemessage(message msg) { try { Thread.sleep(5000); catch (InterruptedException e) { Thread.currentThread().interrupt(); public void oncreate() { HandlerThread thread = new HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND); thread.start();

23 23 Example of service (cont d) // Get the HandlerThread's Looper and use it for our Handler servicelooper = thread.getlooper(); servicehandler = new public int onstartcommand(intent intent, int flags, int startid) { Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show(); Message msg = servicehandler.obtainmessage(); msg.arg1 = startid; servicehandler.sendmessage(msg); return public IBinder onbind(intent intent) { // We don't provide binding, so return null return public void ondestroy() { Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show();

24 Broadcast receivers simply respond to broadcast messages from other applications or from the system itself These messages are sometime called events or intents * 24

25 25 Creating the broadcast receiver A broadcast receiver is implemented as a subclass of BroadcastReceiver class and overriding the onreceive() method where each message is received as a Intent object parameter public class MyReceiver extends BroadcastReceiver public void onreceive(context context, Intent intent) { Toast.makeText(context, "Intent Detected.", Toast.LENGTH_LONG).show();

26 26 Registering broadcast receiver An application listens for specific broadcast intents by registering a broadcast receiver in AndroidManifest.xml file <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <receiver android:name="myreceiver"> <intent-filter> <action android:name="android.intent.action.boot_completed"> </action> </intent-filter> </receiver> </application>

27 27 Sending and receiving a broadcast message To broadcast public void broadcastintent(view view){ Intent intent = new Intent(); intent.setaction( ACTION"); sendbroadcast(intent); To receive public class MyReceiver extends public void onreceive(context context, Intent intent) { Toast.makeText(context, "Intent Detected.", Toast.LENGTH_LONG).show();

28 28 Summary Background processing AsyncTask Service Broadcast receiver

29 29 Lab #5 Implement an example of AsyncTask Please upload zipped project Make a brainstorming with your team for the proposal

30 30 APPENDIX A Methods of AsyncTask

31 31 Methods of AsyncTask Public methods AsyncTask#public-methods Protected methods AsyncTask#protected-methods

32 32 APPENDIX B Event Constants of Intent

33 33 Event constant android.intent.action.battery_changed Sticky broadcast containing the charging state, level, and other information about the battery. android.intent.action.battery_low Indicates low battery condition on the device. android.intent.action.battery_okay Indicates the battery is now okay after being low. android.intent.action.boot_completed This is broadcast once, after the system has finished booting. android.intent.action.bug_report Show activity for reporting a bug. android.intent.action.call Perform a call to someone specified by the data. android.intent.action.call_button The user pressed the "call" button to go to the dialer or other appropriate UI for placing a call. android.intent.action.date_changed The date has changed. android.intent.action.reboot Have the device reboot.

34 34 APPENDIX C Choosing the right background solution for your work

35 35 Selection guide for background processing guide/background

Software Practice 3 Today s lecture Today s Task

Software Practice 3 Today s lecture Today s Task 1 Software Practice 3 Today s lecture Today s Task Prof. Hwansoo Han T.A. Jeonghwan Park 43 2 MULTITHREAD IN ANDROID 3 Activity and Service before midterm after midterm 4 Java Thread Thread is an execution

More information

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

Services. Background operating component without a visual interface Running in the background indefinitely Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android runs in background, they don t have an interface

More information

MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR

MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM Android Component A Service is an application component that runs in the background, not interacting

More information

CS378 -Mobile Computing. Services and Broadcast Receivers

CS378 -Mobile Computing. Services and Broadcast Receivers CS378 -Mobile Computing Services and Broadcast Receivers Services One of the four primary application components: activities content providers services broadcast receivers 2 Services Application component

More information

EMBEDDED SYSTEMS PROGRAMMING Android Services

EMBEDDED SYSTEMS PROGRAMMING Android Services EMBEDDED SYSTEMS PROGRAMMING 2016-17 Android Services APP COMPONENTS Activity: a single screen with a user interface Broadcast receiver: responds to system-wide broadcast events. No user interface Service:

More information

Services. Marco Ronchetti Università degli Studi di Trento

Services. Marco Ronchetti Università degli Studi di Trento 1 Services Marco Ronchetti Università degli Studi di Trento Service An application component that can perform longrunning operations in the background and does not provide a user interface. So, what s

More information

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

Services. service: A background task used by an app. CS 193A Services This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Services service: A background task

More information

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

Outline. Admin. Example: TipCalc. Android: Event Handler Blocking, Android Inter-Thread, Process Communications. Recap: Android UI App Basic Concepts Outline Android: Event Handler Blocking, Android Inter-Thread, Process Communications 10/11/2012 Admin Android Basic concepts Activity, View, External Resources, Listener Inter-thread communications Handler,

More information

Android. Broadcasts Services Notifications

Android. Broadcasts Services Notifications Android Broadcasts Services Notifications Broadcast receivers Application components that can receive intents from other applications Broadcast receivers must be declared in the manifest They have an associated

More information

ANDROID SERVICES, BROADCAST RECEIVER, APPLICATION RESOURCES AND PROCESS

ANDROID SERVICES, BROADCAST RECEIVER, APPLICATION RESOURCES AND PROCESS ANDROID SERVICES, BROADCAST RECEIVER, APPLICATION RESOURCES AND PROCESS 1 Instructor: Mazhar Hussain Services A Service is an application component that can perform long-running operations in the background

More information

Android Fundamentals - Part 1

Android Fundamentals - Part 1 Android Fundamentals - Part 1 Alexander Nelson September 1, 2017 University of Arkansas - Department of Computer Science and Computer Engineering Reminders Projects Project 1 due Wednesday, September 13th

More information

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

Services are software components designed specifically to perform long background operations. SERVICES Service Services are software components designed specifically to perform long background operations. such as downloading a file over an internet connection or streaming music to the user, but

More information

Services. Marco Ronchetti Università degli Studi di Trento

Services. Marco Ronchetti Università degli Studi di Trento 1 Services Marco Ronchetti Università degli Studi di Trento Service An application component that can perform longrunning operations in the background and does not provide a user interface. So, what s

More information

Notifications and Services. Landon Cox March 28, 2017

Notifications and Services. Landon Cox March 28, 2017 Notifications and Services Landon Cox March 28, 2017 Networking so far Volley (retrieve quiz stored at URL) User starts app Check with server for new quiz Say you re building a messaging app How else might

More information

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

App Development for Smart Devices. Lec #7: Windows Azure App Development for Smart Devices CS 495/595 - Fall 2011 Lec #7: Windows Azure Tamer Nadeem Dept. of Computer Science Objective Working in Background AsyncTask Cloud Computing Windows Azure Two Presentation

More information

Embedded Systems Programming - PA8001

Embedded Systems Programming - PA8001 Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 9 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering

More information

Broadcast receivers. Marco Ronchetti Università degli Studi di Trento

Broadcast receivers. Marco Ronchetti Università degli Studi di Trento 1 Broadcast receivers Marco Ronchetti Università degli Studi di Trento Bradcast receiver a component that responds to system-wide broadcast announcements. Many broadcasts originate from the system for

More information

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application.

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application. Learning Unit Exam Project IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application. The delivery of this project is essential

More information

Android Services. Victor Matos Cleveland State University. Services

Android Services. Victor Matos Cleveland State University. Services 22 Android Victor Matos Cleveland State University Notes are based on: Android Developers http://developer.android.com/index.html 22. Android Android A Service is an application component that runs in

More information

Android Services & Local IPC: Overview of Programming Bound Services

Android Services & Local IPC: Overview of Programming Bound Services : Overview of Programming Bound Services d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University Nashville,

More information

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

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml Android Application Written in Java (it s possible to write native code) Good

More information

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables. 1 Thread A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables. Each virtual machine instance has at least one main

More information

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

Android Services & Local IPC: The Command Processor Pattern (Part 1) : The Command Processor Pattern (Part 1) d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University Nashville,

More information

CS371m - Mobile Computing. Responsiveness

CS371m - Mobile Computing. Responsiveness CS371m - Mobile Computing Responsiveness An App Idea From Nifty Assignments Draw a picture use randomness Pick an equation at random Operators in the equation have the following property: Given an input

More information

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Diving into Android. By Jeroen Tietema. Jeroen Tietema, Diving into Android By Jeroen Tietema Jeroen Tietema, 2015 1 Requirements 4 Android SDK 1 4 Android Studio (or your IDE / editor of choice) 4 Emulator (Genymotion) or a real device. 1 See https://developer.android.com

More information

Small talk with the UI thread. Landon Cox March 9, 2017

Small talk with the UI thread. Landon Cox March 9, 2017 Small talk with the UI thread Landon Cox March 9, 2017 Android threads Thread: a sequence of executing instructions Every app has a main thread Processes UI events (taps, swipes, etc.) Updates the UI Apps

More information

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

Services & Interprocess Communication (IPC) CS 282 Principles of Operating Systems II Systems Programming for Android Services & Interprocess Communication (IPC) CS 282 Principles of Operating Systems II Systems Programming for Android A Service is an application component that can perform longrunning operations in the

More information

Writing Zippy Android Apps

Writing Zippy Android Apps Writing Zippy Android Apps Brad Fitzpatrick May 20th, 2010 Live Wave: http://bit.ly/au9bpd Outline Me & why I care What is an ANR? Why do you see them? Quantifying responsiveness: jank Android SDK features

More information

An Overview of the Android Programming

An Overview of the Android Programming ID2212 Network Programming with Java Lecture 14 An Overview of the Android Programming Hooman Peiro Sajjad KTH/ICT/SCS HT 2016 References http://developer.android.com/training/index.html Developing Android

More information

Programming with Android: Notifications, Threads, Services. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: Notifications, Threads, Services. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: Notifications, Threads, Dipartimento di Scienze dell Informazione Università di Bologna Outline Notification : Status Bar Notifications Notification : Toast Notifications Thread

More information

LECTURE 12 BROADCAST RECEIVERS

LECTURE 12 BROADCAST RECEIVERS MOBILE APPLICATION DEVELOPMENT LECTURE 12 BROADCAST RECEIVERS IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM Application Building Blocks Android Component Activity UI Component Typically Corresponding

More information

Podstawowe komponenty aplikacji, wymiana międzyprocesowa

Podstawowe komponenty aplikacji, wymiana międzyprocesowa Podstawowe komponenty aplikacji, wymiana międzyprocesowa Intencje. Budowanie intencji, komunikacja z wykorzystaniem intencji pomiędzy aktywnościami i aplikacjami. Obsługa powiadomień za pomocą klasy BroadcastReceiver.

More information

CS434/534: Topics in Networked (Networking) Systems

CS434/534: Topics in Networked (Networking) Systems CS434/534: Topics in Networked (Networking) Systems Mobile System: Android Component Composition/ Inter-process Communication (IPC) Yang (Richard) Yang Computer Science Department Yale University 208A

More information

Upcoming Assignments Quiz Friday? Lab 5 due today Alpha Version due Friday, February 26

Upcoming Assignments Quiz Friday? Lab 5 due today Alpha Version due Friday, February 26 Upcoming Assignments Quiz Friday? Lab 5 due today Alpha Version due Friday, February 26 Inject one subtle defect (fault seeding) To be reviewed by a few class members Usability study by CPE 484 students

More information

Software Practice 3 Today s lecture Today s Task Porting Android App. in real device

Software Practice 3 Today s lecture Today s Task Porting Android App. in real device 1 Software Practice 3 Today s lecture Today s Task Porting Android App. in real device Prof. Hwansoo Han T.A. Jeonghwan Park 43 INTENT 2 3 Android Intent An abstract description of a message Request actions

More information

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

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Entire Lifetime An activity begins its lifecycle when entering the oncreate() state If not interrupted

More information

App Development for Android. Prabhaker Matet

App Development for Android. Prabhaker Matet App Development for Android Prabhaker Matet Development Tools (Android) Java Java is the same. But, not all libs are included. Unused: Swing, AWT, SWT, lcdui Android Studio (includes Intellij IDEA) Android

More information

Tabel mysql. Kode di PHP. Config.php. Service.php

Tabel mysql. Kode di PHP. Config.php. Service.php Tabel mysql Kode di PHP Config.php Service.php Layout Kode di Main Activity package com.example.mini.webandroid; import android.app.progressdialog; import android.os.asynctask; import android.support.v7.app.appcompatactivity;

More information

INTRODUCTION TO ANDROID

INTRODUCTION TO ANDROID INTRODUCTION TO ANDROID 1 Niv Voskoboynik Ben-Gurion University Electrical and Computer Engineering Advanced computer lab 2015 2 Contents Introduction Prior learning Download and install Thread Android

More information

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

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Android Lifecycle An activity begins its lifecycle when entering the oncreate() state If not

More information

App Development for Smart Devices. Lec #4: Services and Broadcast Receivers

App Development for Smart Devices. Lec #4: Services and Broadcast Receivers App Development for Smart Devices CS 495/595 - Fall 2012 Lec #4: Services and Broadcast Receivers Tamer Nadeem Dept. of Computer Science Objective Working in Background Services AsyncTask Student Presentations

More information

Multiple Activities. Many apps have multiple activities

Multiple Activities. Many apps have multiple activities Intents Lecture 7 Multiple Activities Many apps have multiple activities An activity A can launch another activity B in response to an event The activity A can pass data to B The second activity B can

More information

Android Service. Lecture 19

Android Service. Lecture 19 Android Service Lecture 19 Services Service: A background task used by an app. Example: Google Play Music plays the music using a service Example: Web browser runs a downloader service to retrieve a file

More information

shared objects monitors run() Runnable start()

shared objects monitors run() Runnable start() Thread Lecture 18 Threads A thread is a smallest unit of execution Each thread has its own call stack for methods being invoked, their arguments and local variables. Each virtual machine instance has at

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 - recap Views and Layouts Events Basic application components Activities Intents 9/15/2014

More information

Services Broadcast Receivers Permissions

Services Broadcast Receivers Permissions Services Broadcast Receivers Permissions Runs in the background Extends Service Java class Not necessarily connected to the user s visual interface Music player working in foreground User wants read email

More information

Efficient Android Threading

Efficient Android Threading .... - J.', ' < '.. Efficient Android Threading Anders Göransson Beijing Cambridge Farnham Köln Sebastopol Tokyo O'REILLY Table of Contents Preface xi 1. Android Components and the Need for Multiprocessing

More information

Mobile and Ubiquitous Computing: Android Programming (part 4)

Mobile and Ubiquitous Computing: Android Programming (part 4) Mobile and Ubiquitous Computing: Android Programming (part 4) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Examples from: Mobile and Ubiquitous Computing Jo Vermeulen,

More information

Lecture 2 Android SDK

Lecture 2 Android SDK Lecture 2 Android SDK This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a

More information

Application Fundamentals

Application Fundamentals Application Fundamentals CS 2046 Mobile Application Development Fall 2010 Announcements CMS is up If you did not get an email regarding this, see me after class or send me an email. Still working on room

More information

UNDERSTANDING ACTIVITIES

UNDERSTANDING ACTIVITIES Activities Activity is a window that contains the user interface of your application. An Android activity is both a unit of user interaction - typically filling the whole screen of an Android mobile device

More information

EMBEDDED SYSTEMS PROGRAMMING Application Basics

EMBEDDED SYSTEMS PROGRAMMING Application Basics EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Basics APPLICATIONS Application components (e.g., UI elements) are objects instantiated from the platform s frameworks Applications are event driven ( there

More information

Import the code in the top level sdl_android folder as a module in Android Studio:

Import the code in the top level sdl_android folder as a module in Android Studio: Guides Android Documentation Document current as of 12/22/2017 10:31 AM. Installation SOURCE Download the latest release from GitHub Extract the source code from the archive Import the code in the top

More information

Minds-on: Android. Session 2

Minds-on: Android. Session 2 Minds-on: Android Session 2 Paulo Baltarejo Sousa Instituto Superior de Engenharia do Porto 2016 Outline Activities UI Events Intents Practice Assignment 1 / 33 2 / 33 Activities Activity An activity provides

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 -recap Views and Layouts Events Basic application components Activities Intents BroadcastReceivers

More information

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

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II) Lecture 6: Notification and Web Services Notification A notification is a user interface element that you display outside your app's normal

More information

Android Activities. Akhilesh Tyagi

Android Activities. Akhilesh Tyagi Android Activities Akhilesh Tyagi Apps, memory, and storage storage: Your device has apps and files installed andstoredonitsinternaldisk,sdcard,etc. Settings Storage memory: Some subset of apps might be

More information

Android/Java Lightning Tutorial JULY 30, 2018

Android/Java Lightning Tutorial JULY 30, 2018 Android/Java Lightning Tutorial JULY 30, 2018 Java Android uses java as primary language Resource : https://github.mit.edu/6178-2017/lec1 Online Tutorial : https://docs.oracle.com/javase/tutorial/java/nutsandbolts/inde

More information

Android Tutorial: Part 3

Android Tutorial: Part 3 Android Tutorial: Part 3 Adding Client TCP/IP software to the Rapid Prototype GUI Project 5.2 1 Step 1: Copying the TCP/IP Client Source Code Quit Android Studio Copy the entire Android Studio project

More information

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

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie)! Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

More information

Solving an Android Threading Problem

Solving an Android Threading Problem Home Java News Brief Archive OCI Educational Services Solving an Android Threading Problem Introduction by Eric M. Burke, Principal Software Engineer Object Computing, Inc. (OCI) By now, you probably know

More information

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

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie)! Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

More information

Mobile Computing. Introduction to Android

Mobile Computing. Introduction to Android Mobile Computing Introduction to Android Mobile Computing 2011/2012 What is Android? Open-source software stack for mobile devices OS, middleware and key applications Based upon a modified version of the

More information

Getting started: Installing IDE and SDK. Marco Ronchetti Università degli Studi di Trento

Getting started: Installing IDE and SDK. Marco Ronchetti Università degli Studi di Trento Getting started: Installing IDE and SDK Marco Ronchetti Università degli Studi di Trento Alternative: Android Studio http://developer.android.com/develop/index.html 2 Tools behind the scenes dx allows

More information

Create a local SQL database hosting a CUSTOMER table. Each customer includes [id, name, phone]. Do the work inside Threads and Asynctasks.

Create a local SQL database hosting a CUSTOMER table. Each customer includes [id, name, phone]. Do the work inside Threads and Asynctasks. CIS 470 Lesson 13 Databases - Quick Notes Create a local SQL database hosting a CUSTOMER table. Each customer includes [id, name, phone]. Do the work inside Threads and Asynctasks. package csu.matos; import

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 - recap Views and Layouts Events Basic application components Activities Intents 9/22/2017

More information

Activities. https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities

Activities. https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities Activities https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities Overview What is an Activity Starting and stopping activities The Back Stack

More information

Understanding Application

Understanding Application Introduction to Android Application Development, Android Essentials, Fifth Edition Chapter 4 Understanding Application Components Chapter 4 Overview Master important terminology Learn what the application

More information

Security model. Marco Ronchetti Università degli Studi di Trento

Security model. Marco Ronchetti Università degli Studi di Trento Security model Marco Ronchetti Università degli Studi di Trento Security model 2 Android OS is a multi-user Linux in which each application is a different user. By default, the system assigns each application

More information

Lab 5 Periodic Task Scheduling

Lab 5 Periodic Task Scheduling Lab 5 Periodic Task Scheduling Scheduling a periodic task in Android is difficult as it goes against the philosophy of keeping an application active only while the user is interacting with it. You are

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu India Summer 2012 Review Session Android and Web Working with Views Working with Views Create a new Android project. The app name should

More information

CS434/534: Topics in Networked (Networking) Systems

CS434/534: Topics in Networked (Networking) Systems CS434/534: Topics in Networked (Networking) Systems Mobile System: Android (Single App/Process) Yang (Richard) Yang Computer Science Department Yale University 208A Watson Email: yry@cs.yale.edu http://zoo.cs.yale.edu/classes/cs434/

More information

... 1... 2... 2... 3... 3... 4... 4... 5... 5... 6... 6... 7... 8... 9... 10... 13... 14... 17 1 2 3 4 file.txt.exe file.txt file.jpg.exe file.mp3.exe 5 6 0x00 0xFF try { in.skip(9058); catch (IOException

More information

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Software Practice 3 Before we start Today s lecture Today s Task Team organization 1 Software Practice 3 Before we start Today s lecture Today s Task Team organization Prof. Hwansoo Han T.A. Jeonghwan Park 43 2 Lecture Schedule Spring 2017 (Monday) This schedule can be changed M A R

More information

LifeStreet Media Android Publisher SDK Integration Guide

LifeStreet Media Android Publisher SDK Integration Guide LifeStreet Media Android Publisher SDK Integration Guide Version 1.12.0 Copyright 2015 Lifestreet Corporation Contents Introduction... 3 Downloading the SDK... 3 Choose type of SDK... 3 Adding the LSM

More information

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

CS378 - Mobile Computing. Anatomy of an Android App and the App Lifecycle CS378 - Mobile Computing Anatomy of an Android App and the App Lifecycle Application Components five primary components different purposes and different lifecycles Activity single screen with a user interface,

More information

IEMS 5722 Mobile Network Programming and Distributed Server Architecture

IEMS 5722 Mobile Network Programming and Distributed Server Architecture Department of Information Engineering, CUHK MScIE 2 nd Semester, 2016/17 IEMS 5722 Mobile Network Programming and Distributed Server Architecture Lecture 4 HTTP Networking in Android Lecturer: Albert C.

More information

Tishik Int. University / College of Science / IT Dept. This Course based mainly on online sources ADVANCED MOBILE APPLICATIONS / Spring 1

Tishik Int. University / College of Science / IT Dept. This Course based mainly on online sources ADVANCED MOBILE APPLICATIONS / Spring 1 ADVANCED MOBILE APPLICATIONS / 2018-2019 Spring Tishik Int. University / College of Science / IT Dept. Presented By: Mohammad Salim Al-Othman For 4 th Grade Students This Course based mainly on online

More information

CMSC436: Fall 2013 Week 3 Lab

CMSC436: Fall 2013 Week 3 Lab CMSC436: Fall 2013 Week 3 Lab Objectives: Familiarize yourself with the Activity class, the Activity lifecycle, and the Android reconfiguration process. Create and monitor a simple application to observe

More information

Introduction to Android Development

Introduction to Android Development Introduction to Android Development What is Android? Android is the customizable, easy to use operating system that powers more than a billion devices across the globe - from phones and tablets to watches,

More information

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L 2 0 1 5 Activity Basics Manifest File AndroidManifest.xml Central configuration of Android application Defines: Name of application Icon for

More information

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) Network Connection Web Service K Candra Brata andra.course@gmail.com Mobille App Lab 2015-2016 Network Connection http://developer.android.com/training/basics/network-ops/connecting.html

More information

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop Workshop 1. Create an Option Menu, and convert it into Action Bar (Page 1 8) Create an simple Option Menu Convert Option Menu into Action Bar Create Event Listener for Menu and Action Bar Add System Icon

More information

application components

application components What you need to know for Lab 1 code to publish workflow application components activities An activity is an application component that provides a screen with which users can interact in order to do something,

More information

Android System Development Day-4. Team Emertxe

Android System Development Day-4. Team Emertxe Android System Development Day-4 Team Emertxe Android System Service Table of Content Introduction to service Inter Process Communication (IPC) Adding Custom Service Writing Custom HAL Compiling SDK Testing

More information

Android Ecosystem and. Revised v4presenter. What s New

Android Ecosystem and. Revised v4presenter. What s New Android Ecosystem and Revised v4presenter What s New Why Mobile? 5B 4B 3B 2B 1B Landlines PCs TVs Bank users Mobiles 225M AOL 180M 135M 90M 45M 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Quarters

More information

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator. Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New

More information

Table of Content Android Tutorial... 2 Audience... 2 Prerequisites... 2 Copyright & Disclaimer Notice... 2 Overview... 7

Table of Content Android Tutorial... 2 Audience... 2 Prerequisites... 2 Copyright & Disclaimer Notice... 2 Overview... 7 Android Tutorial Table of Content Android Tutorial... 2 Audience... 2 Prerequisites... 2 Copyright & Disclaimer Notice... 2 Overview... 7 Features of Android... 7 Android Applications... 8 Environment

More information

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

Basic UI elements: Defining Activity UI in the code. Marco Ronchetti Università degli Studi di Trento 1 Basic UI elements: Defining Activity UI in the code Marco Ronchetti Università degli Studi di Trento UI Programmatically public class UIThroughCode extends Activity { LinearLayout llayout; TextView tview;

More information

Theme 2 Program Design. MVC and MVP

Theme 2 Program Design. MVC and MVP Theme 2 Program Design MVC and MVP 1 References Next to the books used for this course, this part is based on the following references: Interactive Application Architecture Patterns, http:// aspiringcraftsman.com/2007/08/25/interactiveapplication-architecture/

More information

REMOTE ACCESS TO ANDROID DEVICES. A Project. Presented to the faculty of the Department of Computer Science. California State University, Sacramento

REMOTE ACCESS TO ANDROID DEVICES. A Project. Presented to the faculty of the Department of Computer Science. California State University, Sacramento REMOTE ACCESS TO ANDROID DEVICES A Project Presented to the faculty of the Department of Computer Science California State University, Sacramento Submitted in partial satisfaction of the requirements for

More information

Android Architecture and Binder. Dhinakaran Pandiyan Saketh Paranjape

Android Architecture and Binder. Dhinakaran Pandiyan Saketh Paranjape Android Architecture and Binder Dhinakaran Pandiyan Saketh Paranjape Android Software stack Anatomy of an Android application Activity UI component typically corresponding of one screen Service Background

More information

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server. CSE 660 Lab 7 Submitted by: Arumugam Thendramil Pavai 1)Simple Remote Calculator Server is created using ServerSocket class of java Server.java import java.io.ioexception; import java.net.serversocket;

More information

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

32. And this is an example on how to retrieve the messages received through NFC. 4. In Android applications the User Interface (UI) thread is the main thread. This thread is very important because it is responsible with displaying/drawing and updating UI elements and handling/dispatching

More information

Xin Pan. CSCI Fall

Xin Pan. CSCI Fall Xin Pan CSCI5448 2011 Fall Outline Introduction of Android System Four primary application components AndroidManifest.xml Introduction of Android Sensor Framework Package Interface Classes Examples of

More information

Voice Control SDK. Vuzix M100 Developer SDK. Developer Documentation. Ron DiNapoli Vuzix Corporation Created: July 22, 2015 Last Update: July 22, 2015

Voice Control SDK. Vuzix M100 Developer SDK. Developer Documentation. Ron DiNapoli Vuzix Corporation Created: July 22, 2015 Last Update: July 22, 2015 Voice Control SDK Vuzix M100 Developer SDK Ron DiNapoli Vuzix Corporation Created: July 22, 2015 Last Update: July 22, 2015 Developer Documentation Introduction The Vuzix Voice Control SDK allows you to

More information

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license Android Android Mobile operating system developed by Google A complete stack OS, framework A rich set of applications Email, calendar, browser, maps, text messaging, contacts, camera, dialer, music player,

More information

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

Writing Efficient Drive Apps for Android. Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations Writing Efficient Drive Apps for Android Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations Raise your hand if you use Google Drive source: "put your hands up!" (CC-BY) Raise the other

More information

Implementing a Download Background Service

Implementing a Download Background Service 1 Implementing a Download Background Service Android Services Stefan Tramm Patrick Bönzli Android Experience Day, FHNW 2008-12-03 2 Agenda Part I: Business Part the application some screenshots Part II:

More information

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MAD ASSIGNMENT NO 3 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MainActivity.java File package com.example.tutorialspoint; import android.manifest;

More information