Vienos veiklos būsena. Theory

Size: px
Start display at page:

Download "Vienos veiklos būsena. Theory"

Transcription

1 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 required, for example, to free resources or to save data. It is described in detail in documentation. Activity, created in a running application can be in one of three states: Resumed - Activity is visible on the screen, it is focused and the user can interact with it. This state is sometimes called Running Paused - Activity is not focused, user cannot interact with it, but it is visible (it is covered by another Activity, which doesn t cover the whole screen or is transparent) Stopped - Activity is not visible (is completely covered by another Activity), that is, it is not focused and user cannot interact with it When Activity goes from one state to another, the system invokes its different methods, which we can fill in with our code. This can be illustrated as a diagram: 1

2 To simplify understanding I ve given a brief state description in brackets below the state names. Cross means that Activity does not exist. So we have the following methods that are invoked by the system: oncreate() - invoked when Activity is created for the first time onstart() - invoked before Activity is shown to the user onresume() - invoked before Activity becomes available for user interaction onpause() - invoked before another Activity is shown onstop() - invoked when Activity is not visible to the user ondestroy() - invoked before Activity is destroyed That is, these methods do NOT cause state changes. But vice-versa, state change of an Activity is a trigger which invokes these methods. We are informed about state changes in this way, so we can react accordingly. Let s see in which order are these methods invoked in practice. Practice In this lesson we will have to emulate screen orientation changes. But Android emulator 2.3 does it wrong, so we will use 2.2 version in this project. To do so, we need to create a new AVD version 2.2 2

3 Let s create a project (Note that we use Android 2.2 version): Project name: P0231_OneActivityState Build Target: Android 2.2 Application name: OneActivityState Package name: ru.startandroid.develop.p0231oneactivitystate Create Activity: MainActivity Do not change the layout. It is not important for now. Open MainActivity.java. There is some code by default as usual: package ru.startandroid.develop.p0231oneactivitystate; import android.app.activity; import android.os.bundle; public class MainActivity extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); We can see, that already familiar for us oncreate method is already implemented. I will repeat once again, it is important to understand that this method does NOT create an Activity. Creation is the system business. That is, the system creates an Activity and gives us an opportunity to participate in it and run our own code inside oncreate() method. We use this opportunity and tell the system that Activity should display the screen from R.layout.main. Let s add all the remaining methods from the diagram and add log entry to each of them. package ru.startandroid.develop.p0231oneactivitystate; import android.app.activity; import android.os.bundle; import android.util.log; public class MainActivity extends Activity { final String TAG = "States"; /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Log.d(TAG, "MainActivity: oncreate()"); protected void onstart() { super.onstart(); Log.d(TAG, "MainActivity: onstart()"); protected void onresume() { 3

4 super.onresume(); Log.d(TAG, "MainActivity: onresume()"); protected void onpause() { super.onpause(); Log.d(TAG, "MainActivity: onpause()"); protected void onstop() { super.onstop(); Log.d(TAG, "MainActivity: onstop()"); protected void ondestroy() { super.ondestroy(); Log.d(TAG, "MainActivity: ondestroy()"); While implementing these methods always invoke the corresponding superclass methods and always before your code. See the code above. Each method contains superclass method invocation and our own code is located after it. Now, when the methods will be invoked we will see it in logs. Configure filter for the "States" tag, to not look for your messages in the pile of other logs. We ve learnt how it is done in the lesson 12 Save everything and run the application. After running see the log: MainActivity: oncreate() MainActivity: onstart() MainActivity: onresume() Activity has been created, passed two states (Stopped, Paused) and now is in the third state - Resumed. It means it was created (oncreate), displayed (onstart) and gained the ability to interact with the user (onresume). Now press the Back button in the emulators. Activity has closed. See the log: 4

5 MainActivity: onpause() MainActivity: onstop() MainActivity: ondestroy() Activity does the opposite to its creation. At first, the focus is lost (onpause ), than it disappears from the screen (onstop), then destroyed completely (ondestroy). Screen orientation change Let s see how will Activity behave when we change our screen orientation. Run the application again (or find it in the list of running applications on the emulator or press CTRL + F11 in Eclipse). Three methods that were invoked on creation are displayed. Now press CTRL + F12 in the emulator, the orientation has changed. It looks like nothing special has happened, but have a look at the logs and see: MainActivity: onpause() MainActivity: onstop() MainActivity: ondestroy() MainActivity: oncreate() MainActivity: onstart() MainActivity: onresume() Activity is completely destroyed and created again. During this process, procedures of saving and restoring data usually occur, not to lose data and for application to save its appearance. We will talk in the next lessons about how it is done. There is also onrestart method. It is invoked before onstart if Activity is not created from scratch but is restored from the Stopped state. We will have look at this method in the next lesson. Usually in books this topic is presented a little bit different. But as for me, this template explanation seems not very clear, that s why I ve written my own. As usual, I hope that I ve managed to explain the subject well ) My advice for you is, after this lesson - to read documentation, link to which I ve provided in the beginning of the lesson. Everything is written very well there. And you will remember everything better. But for now, the most important thing is to understand in which moment each method is invoked. And later we will look through how we can use it and what to code there. 5

6 Dviejų veiklų būsena Let s create a project: Project name: P0241_TwoActivityState Build Target: Android Application name: TwoActivityState Package name: ru.startandroid.develop.p0241twoactivitystate Create Activity: MainActivity Write the following in main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="hello World, MainActivity!"> </TextView> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="go to Activity Two" android:id="@+id/btnacttwo"> </Button> </LinearLayout> "Go to Activity Two" button will invoke the second Activity. Open MainActivity.java and write there all methods, including onrestart this time, and write log entries inside these methods. We also find and define the button and assign alistener to it. Do not write anything inside onclick method for now. package ru.startandroid.develop.p0241twoactivitystate; import android.app.activity; import android.content.intent; import android.os.bundle; import android.util.log; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; public class MainActivity extends Activity implements OnClickListener { final String TAG = "States"; Button btnacttwo; 6

7 public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); btnacttwo = (Button) findviewbyid(r.id.btnacttwo); btnacttwo.setonclicklistener(this); Log.d(TAG, "MainActivity: oncreate()"); protected void onrestart() { super.onrestart(); Log.d(TAG, "MainActivity: onrestart()"); protected void onstart() { super.onstart(); Log.d(TAG, "MainActivity: onstart()"); protected void onresume() { super.onresume(); Log.d(TAG, "MainActivity: onresume()"); protected void onpause() { super.onpause(); Log.d(TAG, "MainActivity: onpause()"); protected void onstop() { super.onstop(); Log.d(TAG, "MainActivity: onstop()"); protected void ondestroy() { super.ondestroy(); Log.d(TAG, "MainActivity: ondestroy()"); public void onclick(view v) { 7

8 In the previous lesson we have seen which methods and in which order are invoked while working with one Activity. Now we are interested in behaviour having two Activities, that s why we create the second Activity. Let s name it ActivityTwo. Remember the previous lessons: we have to create a class with the same name which is a subclass of android.app.activity and register the new Activity inside the manifest-file. We also need to create a layout-file, name it two.xml and fill it in with the following code: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="this is Activity Two"> </TextView> </LinearLayout> We have just a TextView with some text to be clear that this is ActivityTwo. Create a class. ActivityTwo.java code: package ru.startandroid.develop.p0241twoactivitystate; import android.app.activity; import android.os.bundle; import android.util.log; public class ActivityTwo extends Activity { final String TAG = "States"; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.two); Log.d(TAG, "ActivityTwo: oncreate()"); protected void onrestart() { super.onrestart(); Log.d(TAG, "ActivityTwo: onrestart()"); protected void onstart() { super.onstart(); Log.d(TAG, "ActivityTwo: onstart()"); 8

9 protected void onresume() { super.onresume(); Log.d(TAG, "ActivityTwo: onresume()"); protected void onpause() { super.onpause(); Log.d(TAG, "ActivityTwo: onpause()"); protected void onstop() { super.onstop(); Log.d(TAG, "ActivityTwo: onstop()"); protected void ondestroy() { super.ondestroy(); Log.d(TAG, "ActivityTwo: ondestroy()"); Don t forget to add the record about ActivityTwo to the manifest. And now we can add the onclick method code to MainActivity.java, invoking ActivityTwo there public void onclick(view v) { Intent intent = new Intent(this, ActivityTwo.class); startactivity(intent); (add only the underlined code). Log filter should remain from the previous lesson. We will use it. If not, create the filter by the tag States. Save everything and run the application. Step 1. Run the application. MainActivity appeared. 9

10 Logs: MainActivity: oncreate() MainActivity: onstart() MainActivity: onresume() Everything as the previous time - three methods are invoked. Activity goes through Stopped, Paused states and remains in the Resumed state. Step 2. Press "Go to Activity Two" button and ActivityTwo will appear. Logs: MainActivity: onpause() ActivityTwo: oncreate() ActivityTwo: onstart() ActivityTwo: onresume() MainActivity: onstop() Let s look through it. MainActivty.onPause invocation means that MainActivity loses its focus and goes to Pause state. After this, ActivityTwo is created (oncreate), displayed (onstart) and receives focus (onresume). After this MainActivity is not visible any more (onstop). Note, that ondestroy is not invoked for MainActivity and it means it is not destroyed. MainActivity remains in memory in the Stopped state. And ActivityTwo - is in the Resumed state. It is visible and focused, we can interact with it. 10

11 Step 3. Press the Back button on the emulator. We ve returned to the MainActivity. Logs: ActivityTwo: onpause() MainActivity: onrestart() MainActivity: onstart() MainActivity: onresume() ActivityTwo: onstop() ActivityTwo: ondestroy() ActivityTwo.onPause means that ActivityTwo loses its focus and goes to the Paused state. MainActivity now has to be restored from the Stopped state. In the end of the previous lesson I ve written: "onrestart method is invoked before the onstart method, if Activity is not created from scratch, but restored from the Stopped state" - this is exactly our case, MainActivity hasn t been killed by the system, it was still in memory. That is why MainActivity.onRestart is invoked. After this MainActivity.onStart and MainActivity.onResume are invoked - it means MainActivity went to Paused state (was displayed) and Resumed state (gained focus). And onstop and ondestroy methods invocation means that ActivityTwo changed its state to Stopped (was not visible any more) and has been destroyed. Step 4. Press back once again and the application is closed. 11

12 Logs: MainActivity: onpause() MainActivity: onstop() MainActivity: ondestroy() Logs show that MainActivity changed its state to Paused, Stopped and has been destroyed. If it is not clear from the fis time, try to repeat the algorithm for several times and check it with the diagram from the previous lesson. It is quite obvious and it will help you to get through. Try to draw the whole diagram on the sheet of paper and changes of the Activity state. I will also display the sequence of steps here to make it obvious. We found out that Activity is not necessarily destroyed when it is not visible and can be stored in RAM. Looking through this, I guess a question has appeared: why in the step 2 MainActivity disappeared from the screen, but was left in memory and was not destroyed? But in the step 3 ActivityTwo was destroyed just after it disappeared from the screen. And in the step 4 in the end MainActivity was destroyed. Why is step 2 exceptional? We will talk about this in the next lesson, as this lesson is already quite complicated. But the topic is extremely important and is one of the key concepts of the Android operating system. 12

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 - 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

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

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

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

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

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

android:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"

android:orientation=horizontal android:layout_margintop=30dp> <Button android:text=button2 Parametrų keitimas veikiančioje aplikacijoje Let s create a project: Project name: P0181_DynamicLayout3 Build Target: Android 2.3.3 Application name: DynamicLayout3 Package name: ru.startandroid.develop.dynamiclayout3

More information

Meniu. Create a project:

Meniu. Create a project: Meniu Create a project: Project name: P0131_MenuSimple Build Target: Android 2.3.3 Application name: MenuSimple Package name: ru.startandroid.develop.menusimple Create Activity: MainActivity Open MainActivity.java.

More information

<uses-permission android:name="android.permission.internet"/>

<uses-permission android:name=android.permission.internet/> Chapter 11 Playing Video 11.1 Introduction We have discussed how to play audio in Chapter 9 using the class MediaPlayer. This class can also play video clips. In fact, the Android multimedia framework

More information

Android Workshop: Model View Controller ( MVC):

Android Workshop: Model View Controller ( MVC): Android Workshop: Android Details: Android is framework that provides java programmers the ability to control different aspects of smart devices. This interaction happens through the Android SDK (Software

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

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

Intents. Your first app assignment

Intents. Your first app assignment Intents Your first app assignment We will make this. Decidedly lackluster. Java Code Java Code XML XML Preview XML Java Code Java Code XML Buttons that work

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

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

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

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

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

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

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 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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape ON REVERSE PORTRAIT Android: all four orientations are

More information

ELET4133: Embedded Systems. Topic 15 Sensors

ELET4133: Embedded Systems. Topic 15 Sensors ELET4133: Embedded Systems Topic 15 Sensors Agenda What is a sensor? Different types of sensors Detecting sensors Example application of the accelerometer 2 What is a sensor? Piece of hardware that collects

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

Android Programs Day 5

Android Programs Day 5 Android Programs Day 5 //Android Program to demonstrate the working of Options Menu. 1. Create a New Project. 2. Write the necessary codes in the MainActivity.java to create OptionMenu. 3. Add the oncreateoptionsmenu()

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Tip: Switching UIs THE PROBLEM How to switch from one UI to another Each UI is associated with a distinct class that controls it Solution shown: two UIs,

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

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

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

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed.

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed. Action Bar Introduction The Action Bar is a widget that is shown on top of the screen. It includes the application logo on its left side together with items available from the options menu on the right.

More information

Basic GUI elements - exercises

Basic GUI elements - exercises Basic GUI elements - exercises https://developer.android.com/studio/index.html LIVE DEMO Please create a simple application, which will be used to calculate the area of basic geometric figures. To add

More information

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27 Android Coding Dr. J.P.E. Hodgson August 23, 2010 Dr. J.P.E. Hodgson () Android Coding August 23, 2010 1 / 27 Outline Starting a Project 1 Starting a Project 2 Making Buttons Dr. J.P.E. Hodgson () Android

More information

Android Beginners Workshop

Android Beginners Workshop Android Beginners Workshop at the M O B IL E M O N D AY m 2 d 2 D E V E L O P E R D A Y February, 23 th 2010 Sven Woltmann, AndroidPIT Sven Woltmann Studied Computer Science at the TU Ilmenau, 1994-1999

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

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

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology Android App Development Mr. Michaud ICE Programs Georgia Institute of Technology Android Operating System Created by Android, Inc. Bought by Google in 2005. First Android Device released in 2008 Based

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

CS 4330/5390: Mobile Application Development Exam 1

CS 4330/5390: Mobile Application Development Exam 1 1 Spring 2017 (Thursday, March 9) Name: CS 4330/5390: Mobile Application Development Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and closed-book.

More information

Manifest.xml. Activity.java

Manifest.xml. Activity.java Dr.K.Somasundaram Ph.D Professor Department of Computer Science and Applications Gandhigram Rural Institute, Gandhigram, Tamil Nadu-624302, India ka.somasundaram@gmail.com Manifest.xml

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

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

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

App Development for Smart Devices. Lec #18: Advanced Topics

App Development for Smart Devices. Lec #18: Advanced Topics App Development for Smart Devices CS 495/595 - Fall 2011 Lec #18: Advanced Topics Tamer Nadeem Dept. of Computer Science Objective Web Browsing Android Animation Android Backup Presentation - Developing

More information

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation 1. Location Services 1.1 GPS Location 1. Create the Android application with the following attributes. Application Name: MyLocation Project Name: Package Name: MyLocation com.example.mylocation 2. Put

More information

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2 Workshop 1. Compare different layout by using Change Layout button (Page 1 5) Relative Layout Linear Layout (Horizontal) Linear Layout (Vertical) Frame Layout 2. Revision on basic programming skill - control

More information

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard. 44 CHAPTER 2 Android s development environment Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard. TIP You ll want the package name of your applications to be unique

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

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

Our First Android Application

Our First Android Application Mobile Application Development Lecture 04 Imran Ihsan Our First Android Application Even though the HelloWorld program is trivial in introduces a wealth of new ideas the framework, activities, manifest,

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

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location.

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location. 2011 Marty Hall Android Programming Basics Originals of Slides and Source Code for Examples: http://www.coreservlets.com/android-tutorial/ Customized Java EE Training: http://courses.coreservlets.com/

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

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

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics Chapter 10 Speech Recognition 10.1 Introduction Speech recognition (SR) by machine, which translates spoken words into text has been a goal of research for more than six decades. It is also known as automatic

More information

Create Parent Activity and pass its information to Child Activity using Intents.

Create Parent Activity and pass its information to Child Activity using Intents. Create Parent Activity and pass its information to Child Activity using Intents. /* MainActivity.java */ package com.example.first; import android.os.bundle; import android.app.activity; import android.view.menu;

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

Simple Currency Converter

Simple Currency Converter Simple Currency Converter Implementing a simple currency converter: USD Euro Colon (CR) Note. Naive implementation using the rates 1 Costa Rican Colon = 0.001736 U.S. dollars 1 Euro = 1.39900 U.S. dollars

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

Let s take a display of HTC Desire smartphone as an example. Screen size = 3.7 inches, resolution = 800x480 pixels.

Let s take a display of HTC Desire smartphone as an example. Screen size = 3.7 inches, resolution = 800x480 pixels. Screens To begin with, here is some theory about screens. A screen has such physical properties as size and resolution. Screen size - a distance between two opposite corners of the screens, usually measured

More information

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 Comment and Evaluation: This lab introduces us about Android SDK and how to write a program for Android platform. The calculator is pretty easy, everything

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

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

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MAD ASSIGNMENT NO 2 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. Android Widgets There are given a lot of android widgets with simplified

More information

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI Specification: Approaches UIS: APPROACHES Programmatic approach: UI elements are created inside the application code Declarative approach: UI elements are listed

More information

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento Let s work with the listener Button button = ; button.setonclicklistener(new.onclicklistener() { public void

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

COMP4521 EMBEDDED SYSTEMS SOFTWARE

COMP4521 EMBEDDED SYSTEMS SOFTWARE COMP4521 EMBEDDED SYSTEMS SOFTWARE LAB 1: DEVELOPING SIMPLE APPLICATIONS FOR ANDROID INTRODUCTION Android is a mobile platform/os that uses a modified version of the Linux kernel. It was initially developed

More information

Android Data Storage

Android Data Storage Lesson 14 Android Persistency: Victor Matos Cleveland State University Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9

More information

Programming Mobile Applications with Android Lab2

Programming Mobile Applications with Android Lab2 Programming Mobile Applications Lab2 22-26 September, Albacete, Spain Jesus Martínez-Gómez .- Create, compile and execute an Android application to understand the Android life cycle Follow the instructions

More information

Notification mechanism

Notification mechanism Notification mechanism Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University. Portions of this page are reproduced from work created

More information

Database Development In Android Applications

Database Development In Android Applications ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Database Development In Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran

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

ABSTRACT I. INTRODUCTION. E. Susmitha, M. Himabindu M.Tech Academic Assistant, IIIT Rk Valley, Rgukt, Andhra Pradesh, India

ABSTRACT I. INTRODUCTION. E. Susmitha, M. Himabindu M.Tech Academic Assistant, IIIT Rk Valley, Rgukt, Andhra Pradesh, India International Journal of Scientific Research in Computer Science, Engineering and Information Technology 2018 IJSRCSEIT Volume 3 Issue 5 ISSN : 2456-3307 Android based Mobile Application Development by

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

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

By Ryan Hodson. Foreword by Daniel Jebaraj

By Ryan Hodson. Foreword by Daniel Jebaraj 1 By Ryan Hodson Foreword by Daniel Jebaraj 2 Copyright 2014 by Syncfusion Inc. 2501 Aerial Center Parkway Suite 200 Morrisville, NC 27560 USA All rights reserved. I mportant licensing information. Please

More information

Comp 595MC/L: Mobile Computing CSUN Computer Science Department Fall 2013 Midterm

Comp 595MC/L: Mobile Computing CSUN Computer Science Department Fall 2013 Midterm Comp 595MC/L: Mobile Computing CSUN Computer Science Department Fall 2013 Midterm Time: 50 minutes Good news: You can use ONE sheet of notes. Bad news: Closed book, no electronic computing or communications

More information

android-espresso #androidespresso

android-espresso #androidespresso android-espresso #androidespresso Table of Contents About 1 Chapter 1: Getting started with android-espresso 2 Remarks 2 Examples 2 Espresso setup instructions 2 Checking an Options Menu items (using Spoon

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

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

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

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

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

Android HelloWorld - Example. Tushar B. Kute,

Android HelloWorld - Example. Tushar B. Kute, Android HelloWorld - Example Tushar B. Kute, http://tusharkute.com Anatomy of Android Application Anatomy of Android Application Java This contains the.java source files for your project. By default, it

More information

Statistics http://www.statista.com/topics/840/smartphones/ http://www.statista.com/topics/876/android/ http://www.statista.com/statistics/271774/share-of-android-platforms-on-mobile-devices-with-android-os/

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

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

Arrays of Buttons. Inside Android

Arrays of Buttons. Inside Android Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.

More information

M.A.D Assignment # 1

M.A.D Assignment # 1 Submitted by: Rehan Asghar Roll no: BSSE (7) 15126 M.A.D Assignment # 1 Submitted to: Sir Waqas Asghar Submitted by: M. Rehan Asghar 4/25/17 Roll no: BSSE 7 15126 XML Code: Calculator Android App

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

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

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

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Shared Preferences 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran Tanveer, ITU Experts

More information

App Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out

App Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out App Development for Smart Devices CS 495/595 - Fall 2013 Lec #7: Audio, Video & Telephony Try It Out Tamer Nadeem Dept. of Computer Science Trt It Out Example - SoundPool Example - VideoView Page 2 Fall

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

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

Upon completion of the second part of the lab the students will have:

Upon completion of the second part of the lab the students will have: ETSN05, Fall 2017, Version 2.0 Software Development of Large Systems Lab 2 1. INTRODUCTION The goal of lab 2 is to introduce students to the basics of Android development and help them to create a starting

More information

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control. A TextView displays text to the user. TextView Attributes TextView Control android:id - This is the ID which uniquely identifies the control. android:capitalize - If set, specifies that this TextView has

More information

Basics of Android Operating System

Basics of Android Operating System Basics of Android Operating System Android is an open source and Linux-based operating system for mobile devices such as smartphones and tablet computers. Android was developed by the Open Handset Alliance,

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