Android Activities. Akhilesh Tyagi

Size: px
Start display at page:

Download "Android Activities. Akhilesh Tyagi"

Transcription

1 Android Activities Akhilesh Tyagi

2 Apps, memory, and storage storage: Your device has apps and files installed andstoredonitsinternaldisk,sdcard,etc. Settings Storage memory: Some subset of apps might be currently loaded into the device's RAM and are either running or ready to be run. When the user loads an app, it is loaded from storage into memory. When the user exits an app, it might be cleared from memory, or might remain in memory so you can go back to it later. See which apps are in memory: Settings Apps Running

3 Components Android applications utilize four basic components. Activity Service Broadcast Content provider An application can be made up of many of these components.

4 Android App Architecture activity Content provider intent servic e

5 Application Lifecycle Active Active (foreground) processes are those hosting applications with components currently interacting with the user Activities in an active state; Broadcast receivers executing onreceive event handlers. Services executing onstart, oncreate or ondestroy event handlers

6 Application Lifecycle contd. Visible Visible, but inactive processes are those hosting visible Activities Started service Processes hosting Services that have been started Background Processes hosting Activities that aren t visible and that don t have any Services that have been started last seen first killed. Empty An application reached end of lifetime.

7 App Priority

8 import android.app.application; import android.content.res.configuration; Application class public class MyApplication extends Application { private static MyApplication singleton; // Returns the application instance public static MyApplication getinstance() { return public final void oncreate() { super.oncreate(); singleton = this;

9 @Override public final void onlowmemory() { public final void ontrimmemory(int level) { public final void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig);

10 Activity state An activity can be thought of as being in one of several states: starting: In process of loading up, but not fully loaded. running: Done loading and now visible on the screen. paused: Partially obscured or out of focus, but not shut down. stopped: No longer active, but still in the device's active memory. destroyed: Shut down and no longer currently loaded in memory. Transitions between these states are represented by events that you can listen to in your activity code. oncreate, onpause, onresume, onstop, ondestroy,...

11 Activity lifecycle

12 Creating an Activity package edu.iastate.myapplication; import android.app.activity; import android.os.bundle; public class MyActivity extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate);

13

14 Two Views of Activity State Transitions

15 Inflating an XML resource public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main);

16 Activity Registration (Manifest) <activity android:name=.myactivity > <intent filter> <action android:name= android.intent.action.main /> <category android:name= android.intent.category.launcher /> </intent filter> </activity>

17 Activity Intents new application contains the stub activity that includes an intent filter that declares the activity responds to the "main" action and should be placed in the "launcher" category <action> element specifies that this is the "main" entry point to the application <category> element specifies that this activity should be listed in the system's application launcher

18 Activity Intents start another activity by calling startactivity(), passing it an Intent. Intent intent = new Intent(this, SignInActivity.class); startactivity(intent); Intent intent = new Intent(Intent.ACTION_SEND); intent.putextra(intent.extra_ , recipientarray); startactivity(intent);

19 Shutting down an activity shut down an activity by calling its finish() method You can also shut down a separate activity that you previously started by calling finishactivity()

20

21 Activity Stack

22 The oncreate method In oncreate, you create and set up the activity object, load any static resources like images, layouts, set up menus etc. after this, the Activity object exists think of this as the "constructor" of the activity public class FooActivity extends Activity {... public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // always call super setcontentview(r.layout.activity_foo); // set up layout any other initialization code; // anything else you need Marty Stepp, Stanford, CS193A

23 The onpause method When onpause is called, your activity is still partially visible. May be temporary, or on way to termination. Stop animations or other actions that consume CPU. Commit unsaved changes (e.g. draft ). Release system resources that affect battery life. public void onpause() { super.onpause(); // always call super if (myconnection!= null) { myconnection.close(); // release resources myconnection = null; Marty Stepp, Stanford, CS193A

24 The onresume method When onresume is called, your activity is coming out of the Paused state and into the Running state again. Also called when activity is first created/loaded! Initialize resources that you will release in onpause. Start/resume animations or other ongoing actions that should only run when activity is visible on screen. public void onresume() { super.onpause(); // always call super if (myconnection == null) { myconnection = new ExampleConnect(); // init.resources myconnection.connect(); Marty Stepp, Stanford, CS193A

25 The onstop method When onstop is called, your activity is no longer visible on the screen: User chose another app from Recent Apps window. User starts a different activity in your app. User receives a phone call while in your app. Your app might still be running, but that activity is not. onpause is always called before onstop. onstop performs heavy duty shutdown tasks like writing to a database. public void onstop() { super.onstop();... // always call super Marty Stepp, Stanford, CS193A

26 onstart and onrestart onstart is called every time the activity begins. onrestart is called when activity was stopped but is started again later (all but the first start). Not as commonly used; favor onresume. Re open any resources that onstop closed. public void onstart() { super.onstart();... public void onrestart() { super.onrestart();... // always call super // always call super Marty Stepp, Stanford, CS193A

27 The ondestroy method When ondestroy is called, your entire app is being shut down and unloaded from memory. Unpredictable exactly when/if it will be called. Can be called whenever the system wants to reclaim the memory used by your app. Generally favor onpause or onstop because they are called in a predictable and timely manner. public void ondestroy() { super.ondestroy();... // always call super Marty Stepp, Stanford, CS193A

28 Testing activity states (link) Use the LogCat system for logging messages when your app changes states: analogous to System.out.println debugging for Android apps appears in the LogCat console in Android Studio public void onstart() { super.onstart(); Log.v("testing", "onstart was called!"); Marty Stepp, Stanford, CS193A

29 Log methods Method Log.d("tag", "message"); Log.e("tag", "message"); Log.i("tag", "message"); Log.v("tag", "message"); Log.w("tag", "message"); Log.wtf("tag", exception); Description debug message (for debugging) error message (fatal error) info message (low urgency FYI) verbose message (rarely shown) warning message (non fatal error) log stack trace of an exception Each method can also accept an optional exception argument: try { somecode(); catch (Exception ex) { Log.e("error4", "something went wrong", ex); Marty Stepp, Stanford, CS193A

30 Activity Life Cycle

31 Method Description Killable after? Next oncreate() Called when the activity is first created. This is where you should do all of your normal static set up create views, bind data to lists, and so on. This method is passed a Bundle object containing the activity's previous state, if that state was captured. Always followed by onstart(). No onstart()

32 onrestart() Called after the activity has been stopped, just prior to it being started again. Always followed by onstart() No onstart() onstart() Called just before the activity becomes visible to the user. Followed by onresume() if the activity comes to the foreground, or onstop() if it becomes hidden. No onresume() or onstop()

33 onresume() onpause() called just before the activity starts interacting with the user. At this point the activity is at the top of the activity stack, with user input going to it. Always followed by onpause(). Called when the system is about to start resuming another activity. This method is typically used to commit unsaved changes to persistent data, stop animations and other things that may be consuming CPU, and so on. It should do whatever it does very quickly, because the next activity will not be resumed until it returns. Followed either by onresume() if the activity returns back to the front, or by onstop() if it becomes invisible to the user. No onpause() Yes onresume() or onstop()

34 onstop() Called when the activity is no longer visible to the user. This may happen because it is being destroyed, or because another activity (either an existing one or a new one) has been resumed and is covering it. Followed either by onrestart() if the activity is coming back to interact with the user, or byondestroy() if this activity is going away. Yes onresta rt() or ondestr oy() ondestr oy() Called before the activity is destroyed. This is the final call that the activity will receive. It could be called either because the activity is finishing (someone called finish() on it), or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isfinishing() method. Yes nothing

35 Activity Lifetimes Full first call to oncreate () to last call to ondestroy (). Activity can be destroyed without a call to ondestroy(). Use the oncreate method to initialize your Activity: Inflate the user interface, allocate references to class variables, bind data to controls, and create Services and threads. The oncreate method is passed a Bundle object containing the UI state saved in the last call to onsaveinstancestate. You should use this Bundle to restore the user interface to its previous state, either in the oncreate method or by overriding onrestoreinstancestate Method.

36 Android doc calls it entire. Your activity should perform setup of "global" state (such as defining layout) in oncreate(), and release all remaining resources in ondestroy(). For example, if your activity has a thread running in the background to download data from the network, it might create that thread in oncreate() and then stop the thread in ondestroy().

37 Activity Lifetimes contd. Visible between calls to onstart and onstop The onstop method should be used to pause or stop animations, threads, timers, Services, or other processes that are used exclusively to update the user interface. There s little value in consuming resources (such as CPU cycles or network bandwidth) to update the UI when it isn t visible. Use the onstart (or onrestart) methods to resume or restart these processes when the UI is visible again.

38 Android Doc version During this time, the user can see the activity onscreen and interact with it. For example, onstop() is called when a new activity starts and this one is no longer visible. Between these two methods, you can maintain resources that are needed to show the activity to the user. For example, you can register a BroadcastReceiver in onstart() to monitor changes that impact your UI, and unregister it in onstop() when the user can no longer see what you are displaying. The system might call onstart() and onstop() multiple times during the entire lifetime of the activity, as the activity alternates between being visible and hidden to the user.

39 Activity Lifetimes Active starts with a call to onresume and ends with a corresponding call to onpause Activity is likely to go through several active lifetimes before it s destroyed, as the active lifetime will end when a new Activity is displayed, the device goes to sleep, or the Activity loses focus. Try to keep code in the onpause and onresume methods relatively fast and lightweight to ensure that your application remains responsive when moving in and out of the foreground.

40 ANDROID DOC: The foreground lifetime of an activity happens between the call to onresume() and the call to onpause(). During this time, the activity is in front of all other activities on screen and has user input focus. An activity can frequently transition in and out of the foreground for example, onpause() is called when the device goes to sleep or when a dialog appears. Because this state can transition often, the code in these two methods should be fairly lightweight in order to avoid slow transitions that make the user wait.

41

42 Basic Life Cycle

43 OnCreate Portion

44 Activity State Event Handlers package edu.iastate.activities; import android.app.activity; import android.os.bundle; public class MyStateChangeActivity extends Activity { // Called at the start of the full public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // Initialize Activity and inflate the UI.

45 // Called after oncreate has finished, use to restore UI public void onrestoreinstancestate(bundle savedinstancestate) { super.onrestoreinstancestate(savedinstancestate); // Restore UI state from the savedinstancestate. // This bundle has also been passed to oncreate. // Will only be called if the Activity has been // killed by the system since it was last visible. // Called before subsequent visible lifetimes // for an activity public void onrestart(){ super.onrestart(); // Load changes knowing that the Activity has already // been visible within this process.

46 // Called at the start of the visible public void onstart(){ super.onstart(); // Apply any required UI change now that the Activity is visible. // Called at the start of the active public void onresume(){ super.onresume(); // Resume any paused UI updates, threads, or processes required // by the Activity but suspended when it was inactive.

47 // Called to save UI state changes at the // end of the active public void onsaveinstancestate(bundle savedinstancestate) { // Save UI state changes to the savedinstancestate. // This bundle will be passed to oncreate and // onrestoreinstancestate if the process is // killed and restarted by the run time. super.onsaveinstancestate(savedinstancestate); // Called at the end of the active public void onpause(){ // Suspend UI updates, threads, or CPU intensive processes // that don't need to be updated when the Activity isn't // the active foreground Activity. super.onpause();

48 // Called at the end of the visible public void onstop(){ // Suspend remaining UI updates, threads, or processing // that aren't required when the Activity isn't visible. // Persist all edits or state changes // as after this call the process is likely to be killed. super.onstop(); // Sometimes called at the end of the full public void ondestroy(){ // Clean up any resources including ending threads, // closing database connections etc. super.ondestroy();

49 DivideAndConquer App Main public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // Turn off the title bar requestwindowfeature(window.feature_no_title); setcontentview(r.layout.main); mballsview = (DivideAndConquerView) findviewbyid(r.id.ballsview); mballsview.setcallback(this); mpercentcontained = (TextView) findviewbyid(r.id.percentcontained); mlevelinfo = (TextView) findviewbyid(r.id.levelinfo); mlivesleft = (TextView) findviewbyid(r.id.livesleft); // we'll vibrate when the ball hits the moving line mvibrator = (Vibrator) getsystemservice(context.vibrator_service);

50 DivideAndConquer Lifecycle protected void onpause() { super.onpause(); mballsview.setmode(divideandconquerview.m ode.pausedbyuser);

51 DivideAndConquer Lifecycle protected void onresume() { super.onresume(); mvibrateon = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Preferences.KEY_VIBRATE, true); mnumlivesstart = Preferences.getCurrentDifficulty(this).getLivesToStart();

52 A representation of how each new activity in a task adds an item to the back stack. When the user presses the Back button, the current activity is destroyed and the previous activity resumes.

53 Backstack Per Application/task Multiple or single activity instance on the backstack Intent for launcher determines some of it

54 A single activity is instantiated multiple times.

55 Two tasks: Task B receives user interaction in the foreground, while Task A is in the background, waiting to be resumed.

56 Activity Launch and Manifest In manifest, specify launch intents. <activity android:name=.myactivity > <intent filter> <action android:name= android.intent.action.main /> <category android:name= android.intent.category.launcher /> </intent filter> </activity>

57 Activity Launch and Manifest contd. an activity in your application to begin a new task when it is started (instead of being placed within the current task) when you start an activity, you want to bring forward an existing instance of it (instead of creating a new instance on top of the back stack) you want your back stack to be cleared of all activities except for the root activity when the user leaves the task.

58 Activity attributes: taskaffinity launchmode allowtaskreparenting cleartaskonlaunch alwaysretaintaskstate finishontasklaunch Intent flags FLAG_ACTIVITY_NEW_TASK FLAG_ACTIVITY_CLEAR_TOP FLAG_ACTIVITY_SINGLE_TOP

59 A representation of how an activity with launch mode "singletask" is added to the back stack. If the activity is already a part of a background task with its own back stack, then the entire back stack also comes forward, on top of the current task

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

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

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

LECTURE NOTES OF APPLICATION ACTIVITIES

LECTURE NOTES OF APPLICATION ACTIVITIES Department of Information Networks The University of Babylon LECTURE NOTES OF APPLICATION ACTIVITIES By College of Information Technology, University of Babylon, Iraq Samaher@inet.uobabylon.edu.iq The

More information

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi Introduction An application is composed of at least one Activity GUI It is a software component that stays behind a GUI (screen) Activity It runs inside the

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

States of Activities. Active Pause Stop Inactive

States of Activities. Active Pause Stop Inactive noname Conceptual Parts States of Activities Active Pause Stop Inactive Active state The state that the activity is on the most foreground and having a focus. This is in Active state. Active state The

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

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

Overview of Activities

Overview of Activities d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems Programming

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

Vienos veiklos būsena. Theory

Vienos veiklos būsena. Theory Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is

More information

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu Android Activity LifeCycle Starting Activities Android applications don't start with a call to main(string[])

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

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

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

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters Mobile Programming Lecture 5 Composite Views, Activities, Intents and Filters Lecture 4 Review How do you get the value of a string in the strings.xml file? What are the steps to populate a Spinner or

More information

University of Babylon - College of IT SW Dep. - Android Assist. Lect. Wadhah R. Baiee Activities

University of Babylon - College of IT SW Dep. - Android Assist. Lect. Wadhah R. Baiee Activities Activities Ref: Wei-Meng Lee, BEGINNING ANDROID 4 APPLICATION DEVELOPMENT, Ch2, John Wiley & Sons, 2012 An application can have zero or more activities. Typically, applications have one or more activities;

More information

Embedded Systems Programming - PA8001

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

More information

Real-Time Embedded Systems

Real-Time Embedded Systems Real-Time Embedded Systems DT8025, Fall 2016 http://goo.gl/azfc9l Lecture 8 Masoumeh Taromirad m.taromirad@hh.se Center for Research on Embedded Systems School of Information Technology 1 / 51 Smart phones

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

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

CS378 -Mobile Computing. Anatomy of and Android App and the App Lifecycle CS378 -Mobile Computing Anatomy of and Android App and the App Lifecycle Hello Android Tutorial http://developer.android.com/resources/tutorials/hello-world.html Important Files src/helloandroid.java Activity

More information

Android framework overview Activity lifecycle and states

Android framework overview Activity lifecycle and states http://www.android.com/ Android framework overview Activity lifecycle and states Major framework terms 1 All Android apps contains at least one of the 4 components Activity (1) Building block of the UI.

More information

Lab 1: Getting Started With Android Programming

Lab 1: Getting Started With Android Programming Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Eng. Jehad Aldahdooh Mobile Computing Android Lab Lab 1: Getting Started With Android Programming To create a new Android Project

More information

Activities and Fragments

Activities and Fragments Activities and Fragments 21 November 2017 Lecture 5 21 Nov 2017 SE 435: Development in the Android Environment 1 Topics for Today Activities UI Design and handlers Fragments Source: developer.android.com

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

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

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering Getting Started Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador 1 Goals Setting up your development environment Android Framework

More information

Have a development environment in 256 or 255 Be familiar with the application lifecycle

Have a development environment in 256 or 255 Be familiar with the application lifecycle Upcoming Assignments Readings: Chapter 4 by today Horizontal Prototype due Friday, January 22 Quiz 2 today at 2:40pm Lab Quiz next Friday during lecture time (2:10-3pm) Have a development environment in

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu Announcements Group formation: Projects 2, 3 and final project will be

More information

Programming in Android. Nick Bopp

Programming in Android. Nick Bopp Programming in Android Nick Bopp nbopp@usc.edu Types of Classes Activity This is the main Android class that you will be using. These are actively displayed on the screen and allow for user interaction.

More information

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi View System A system for organizing GUI Screen = tree of views. View = rectangular shape on the screen that knows how to draw itself wrt to the containing

More information

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time The 1 activity 1 thing the user can do heuristic may not make sense for larger devices Application

More information

Android Basics. Android UI Architecture. Android UI 1

Android Basics. Android UI Architecture. Android UI 1 Android Basics Android UI Architecture Android UI 1 Android Design Constraints Limited resources like memory, processing, battery à Android stops your app when not in use Primarily touch interaction à

More information

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie Android Anatomy Android Anatomy 2! Agenda

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu Administrivia Moved back deadlines for projects 2, 3 and final project See updated schedule

More information

UI Fragment.

UI Fragment. UI Fragment 1 Contents Fragments Overviews Lifecycle of Fragments Creating Fragments Fragment Manager and Transactions Adding Fragment to Activity Fragment-to-Fragment Communication Fragment SubClasses

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

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

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment FRAGMENTS Fragments An activity is a container for views When you have a larger screen device than a phone like a tablet it can look too simple to use phone interface here. Fragments Mini-activities, each

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

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING This document can be downloaded from www.chetanahegde.in with most recent updates. 1 MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING Syllabus: What is Android? Obtaining the required tools, Anatomy

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

Introduction to Android

Introduction to Android Introduction to Android http://myphonedeals.co.uk/blog/33-the-smartphone-os-complete-comparison-chart www.techradar.com/news/phone-and-communications/mobile-phones/ios7-vs-android-jelly-bean-vs-windows-phone-8-vs-bb10-1159893

More information

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu Android UI Design Example GeoQuiz App Reference: Android Nerd Ranch, pgs 1 30 App presents

More information

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2. Outline 1. Set up Android Studio Android development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 15 September 2017 2. Create sample app 3. Add UI to see how the design interface works 4. Add some code

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

Mobila applikationer och trådlösa nät, HI1033, HT2013

Mobila applikationer och trådlösa nät, HI1033, HT2013 Mobila applikationer och trådlösa nät, HI1033, HT2013 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android

More information

Lifecycle Callbacks and Intents

Lifecycle Callbacks and Intents SE 435: Development in the Android Environment Recitations 2 3 Semester 1 5779 4 Dec - 11 Dec 2018 Lifecycle Callbacks and Intents In this recitation we ll prepare a mockup tool which demonstrates the

More information

Mobile Computing Fragments

Mobile Computing Fragments Fragments APM@FEUP 1 Fragments (1) Activities are used to define a full screen interface and its functionality That s right for small screen devices (smartphones) In bigger devices we can have more interface

More information

CS 193A. Activity state and preferences

CS 193A. Activity state and preferences CS 193A Activity state and preferences This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Activity instance

More information

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Activity Logging Lecture 16

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Activity Logging Lecture 16 Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Activity Logging Lecture 16 Hello, last two classes we learned about activity life cycles and the call back

More information

Android Application Development

Android Application Development Android Application Development Octav Chipara What is Android A free, open source mobile platform A Linux-based, multiprocess, multithreaded OS Android is not a device or a product It s not even limited

More information

Fragments and the Maps API

Fragments and the Maps API Fragments and the Maps API Alexander Nelson October 6, 2017 University of Arkansas - Department of Computer Science and Computer Engineering Fragments Fragments Fragment A behavior or a portion of a user

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

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 s Life Cycle

Application s Life Cycle Lesson 3 Application s Life Cycle Victor Matos Cleveland State University Portions of this page are reproduced from work created and shared by Google and used according to terms described in the Creative

More information

Lifecycle-Aware Components Live Data ViewModel Room Library

Lifecycle-Aware Components Live Data ViewModel Room Library Lifecycle-Aware Components Live Data ViewModel Room Library Multiple entry points launched individually Components started in many different orders Android kills components on reconfiguration / low memory

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

Mobile Computing Practice # 2c Android Applications - Interface

Mobile Computing Practice # 2c Android Applications - Interface Mobile Computing Practice # 2c Android Applications - Interface One more step in the restaurants application. 1. Design an alternative layout for showing up in landscape mode. Our current layout is not

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

Mobile Application Development MyRent Settings

Mobile Application Development MyRent Settings Mobile Application Development MyRent Settings Waterford Institute of Technology October 13, 2016 John Fitzgerald Waterford Institute of Technology, Mobile Application Development MyRent Settings 1/19

More information

Introduction to Android

Introduction to Android Introduction to Android Ambient intelligence Teodoro Montanaro Politecnico di Torino, 2016/2017 Disclaimer This is only a fast introduction: It is not complete (only scrapes the surface) Only superficial

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

Android System Architecture. Android Application Fundamentals. Applications in Android. Apps in the Android OS. Program Model 8/31/2015

Android System Architecture. Android Application Fundamentals. Applications in Android. Apps in the Android OS. Program Model 8/31/2015 Android System Architecture Android Application Fundamentals Applications in Android All source code, resources, and data are compiled into a single archive file. The file uses the.apk suffix and is used

More information

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

Mobile Programming Practice Background processing AsynTask Service Broadcast receiver Lab #5 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 Background processing Every Android app has a main

More information

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH Android Basics - Bhaumik Shukla Android Application Developer @ STEALTH FLASH Introduction to Android Android is a software stack for mobile devices that includes an operating system, middleware and key

More information

Mobila applikationer och trådlösa nät, HI1033, HT2012

Mobila applikationer och trådlösa nät, HI1033, HT2012 Mobila applikationer och trådlösa nät, HI1033, HT2012 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android

More information

Computer Science E-76 Building Mobile Applications

Computer Science E-76 Building Mobile Applications Computer Science E-76 Building Mobile Applications Lecture 3: [Android] The SDK, Activities, and Views February 13, 2012 Dan Armendariz danallan@mit.edu 1 http://developer.android.com Android SDK and NDK

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

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

Programming with Android: Intents. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: Intents Luca Bedogni Dipartimento di Scienze dell Informazione Università di Bologna Outline What is an intent? Intent description Handling Explicit Intents Handling implicit

More information

8Messaging SMS MESSAGING.

8Messaging SMS MESSAGING. 8Messaging WHAT YOU WILL LEARN IN THIS CHAPTER How to send SMS messages programmatically from within your application How to send SMS messages using the built-in Messaging application How to receive incoming

More information

Introduction To Android

Introduction To Android Introduction To Android Mobile Technologies Symbian OS ios BlackBerry OS Windows Android Introduction to Android Android is an operating system for mobile devices such as smart phones and tablet computers.

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

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

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

COSC 3P97 Mobile Computing

COSC 3P97 Mobile Computing COSC 3P97 Mobile Computing Mobile Computing 1.1 COSC 3P97 Prerequisites COSC 2P13, 3P32 Staff instructor: Me! teaching assistant: Steve Tkachuk Lectures (MCD205) Web COSC: http://www.cosc.brocku.ca/ COSC

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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 2 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 1 -recap What is Android How to develop Android applications Run & debug the applications

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

Google Maps Troubleshooting

Google Maps Troubleshooting Google Maps Troubleshooting Before you go through the troubleshooting guide below, make sure that you ve consulted the class FAQ, Google s Map Activity Tutorial, as well as these helpful resources from

More information

Mobile User Interfaces

Mobile User Interfaces Mobile User Interfaces CS 2046 Mobile Application Development Fall 2010 Announcements Next class = Lab session: Upson B7 Office Hours (starting 10/25): Me: MW 1:15-2:15 PM, Upson 360 Jae (TA): F 11:00

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

COLLEGE OF ENGINEERING, NASHIK-4

COLLEGE OF ENGINEERING, NASHIK-4 Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK-4 DEPARTMENT OF COMPUTER ENGINEERING 1) What is Android? Important Android Questions It is an open-sourced operating system that is used primarily

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

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

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

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

FRAGMENTS.

FRAGMENTS. Fragments 69 FRAGMENTS In the previous section you learned what an activity is and how to use it. In a small-screen device (such as a smartphone), an activity typically fi lls the entire screen, displaying

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

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

Android for Ubiquitous Computing Researchers. Andrew Rice University of Cambridge 17-Sep-2011

Android for Ubiquitous Computing Researchers. Andrew Rice University of Cambridge 17-Sep-2011 Android for Ubiquitous Computing Researchers Andrew Rice University of Cambridge 17-Sep-2011 Getting started Website for the tutorial: http://www.cl.cam.ac.uk/~acr31/ubicomp/ Contains links to downloads

More information

University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World

University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World Before you do anything read all of the following red paragraph! For this lab you

More information

Mobile Application Development - Android

Mobile Application Development - Android Mobile Application Development - Android MTAT.03.262 Satish Srirama satish.srirama@ut.ee Goal Give you an idea of how to start developing Android applications Introduce major Android application concepts

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

2017 Pearson Educa2on, Inc., Hoboken, NJ. All rights reserved.

2017 Pearson Educa2on, Inc., Hoboken, NJ. All rights reserved. Operating Systems: Internals and Design Principles Chapter 4 Threads Ninth Edition By William Stallings Processes and Threads Resource Ownership Process includes a virtual address space to hold the process

More information

Understanding and Detecting Wake Lock Misuses for Android Applications

Understanding and Detecting Wake Lock Misuses for Android Applications Understanding and Detecting Wake Lock Misuses for Android Applications Artifact Evaluated by FSE 2016 Yepang Liu, Chang Xu, Shing-Chi Cheung, and Valerio Terragni Code Analysis, Testing and Learning Research

More information

Lecture 1 Introduction to Android. App Development for Mobile Devices. App Development for Mobile Devices. Announcement.

Lecture 1 Introduction to Android. App Development for Mobile Devices. App Development for Mobile Devices. Announcement. CSCE 315: Android Lectures (1/2) Dr. Jaerock Kwon App Development for Mobile Devices Jaerock Kwon, Ph.D. Assistant Professor in Computer Engineering App Development for Mobile Devices Jaerock Kwon, Ph.D.

More information