States of Activities. Active Pause Stop Inactive

Similar documents
Minds-on: Android. Session 2

Overview of Activities

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

Activities and Fragments

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

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

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

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

LECTURE NOTES OF APPLICATION ACTIVITIES

Android Activities. Akhilesh Tyagi

Android Fundamentals - Part 1

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

UNDERSTANDING ACTIVITIES

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

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

Activities. Repo:

Lab 1: Getting Started With Android Programming

Lifecycle Callbacks and Intents

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

CMSC436: Fall 2013 Week 3 Lab

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

Lifecycle-Aware Components Live Data ViewModel Room Library

UI Fragment.

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

Vienos veiklos būsena. Theory

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

Mobile Computing Fragments

Understanding Application

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

Android Ecosystem and. Revised v4presenter. What s New

Programming Mobile Applications with Android Lab2

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

Android Application Development

EMBEDDED SYSTEMS PROGRAMMING Application Basics

Android Basics. Android UI Architecture. Android UI 1

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

application components

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

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

Application Fundamentals

Introduction to Android

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

Introduction to Android development

Libraries are wri4en in C/C++ and compiled for the par>cular hardware.

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

CS 193A. Activity state and preferences

Android Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ]

Embedded Systems Programming - PA8001

Real-Time Embedded Systems

Android Programmierung leichtgemacht. Lars Vogel

Mobile Development Lecture 11: Activity State and Preferences

Computer Science E-76 Building Mobile Applications

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

INTRODUCTION TO ANDROID

Introduction to Android

COLLEGE OF ENGINEERING, NASHIK-4

Understanding and Detecting Wake Lock Misuses for Android Applications

Programming with Android: Android for Tablets. Dipartimento di Scienze dell Informazione Università di Bologna

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Understanding and Detecting Wake Lock Misuses for Android Applications

Mobile Computing. Introduction to Android

Mobile User Interfaces

Orientation & Localization

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

Fragments and the Maps API

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

CS 4330/5390: Mobile Application Development Exam 1

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

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu

Application s Life Cycle

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR

ANDROID MOCK TEST ANDROID MOCK TEST IV

CS378 -Mobile Computing. Audio

Lecture 2 Android SDK

Static Detection of Energy Defect Patterns in Android Applications

Software Practice 3 Today s lecture Today s Task

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

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING

Android framework overview Activity lifecycle and states

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

Application s Life Cycle

Mobile Application Programing: Android. View Persistence

COSC 3P97 Mobile Computing

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

Xin Pan. CSCI Fall

Repairing crashes in Android Apps. Shin Hwei Tan Zhen Dong Xiang Gao Abhik Roychoudhury National University of Singapore

CHAPTER 3 APPLICATIONS AND ACTIVITIES

Exercise 1: First Android App

CPET 565 Mobile Computing Systems CPET/ITC 499 Mobile Computing. Lab & Demo 2 (Part 1-2) Hello-Goodbye App Tutorial

Google Maps Troubleshooting

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

Android Overview. Most of the material in this sec5on comes from h6p://developer.android.com/guide/

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

Android Programming Lecture 8: Activities, Odds & Ends, Two New Views 9/28/2011

CS378 -Mobile Computing. Services and Broadcast Receivers

Stanislav Rost CSAIL, MIT

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

MOBILE VIDEO COMMUNICATION ON ANDROID FOR DEAF USERS. Michael B Motlhabi, Mr. William D Tucker, Dr. Baccalaureous Scientiae (Honours)

CHAPTER 3 APPLICATIONS AND ACTIVITIES

Transcription:

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 condition that an activity goes into active state Create > Start > Resume (Pause state) > Resume (Stop state) > Restart > Start > Resume (Inactive state caused by abnormal termination) > Create > Start > RestoreInstanceState > Resume

Pause state The state that the activity is shown in the screen although it does not have a focus because another activity is in active state but occupies just some part of the screen or the full screen with transparency. This is in Pause state. This is in Active state.

Pause state The condition that an activity goes into pause state (Active state) > (Some part of the activity doesn t appear) > SaveInstanceState > Pause

Stop state The state that the activity doesn t appear on the screen because of occupation of an active activity which uses the full screen without transparency. This is in Stop state. This is in Pause state. This is in Active state.

Stop state The condition that an activity goes into stop state (Pause state) > (Any part of the activity doesn t appear) > Stop Create > Start > Stop

Inactive state The state that the activity is terminated or not started yet. The activity cannot appear on the screen until it is (re)started.

Inactive state The condition that an activity goes into inactive state (Pause state) > (Abnormal termination by system) (Stop state) > (Abnormal termination by system) (Stop state) > Destroy

Activity Stack Activities are stacked. The top activity in the stack is being in active state. This is why the back button exists in Android phones and works as we expected.

Application Termination Priority Mobile phones have restricted resources, hence the system terminates the applications whose termination priority is high. An application s priority is determined by its activity which has the highest priority. Forced termination priority Stop state: 1 st Pause state: 2 nd Active state: never

Development Parts

Callback functions Android system provides us with callback functions as handler for changing of states. What we have to do is just implementing the callback functions. Caution: We have to call the original callback function of super class.

oncreate(bundle) When? When the activity is being created. What to do? Setting the layout of the activity with setcontentview(). Creating views. Binding between views and data. Restoring flowing(?) states from Bundle. Followed by onstart()

oncreate(bundle) What is Bundle? Will be explained later.

onrestart() When? When the activity s state is being changed from stop to active. What to do? Similar to oncreate function. Followed by onstart()

onstart() When? When the activity is becoming visible. What to do? Making the activity to be able to be shown. Followed by onresume(): When the activity goes to the foreground. onstop(): When the activity is becoming hidden.

onresume() When? Before the activity s state is changed to active. At this point, the activity is on the top of the activity stack. What to do? Preparing for correct working of the activity. e.g. Occupying a camera device resource. Followed by onpause()

onpause() When? Before the activity s state is changed to pause. What to do? Generally, undoing of onresume function. Releasing occupation. Cleaning data. Saving data to prepare for abnormal termination. Followed by onresume(): When the activity is activated again. onstop() Properties This function s return is guaranteed, and abnormal termination can be done after the return.

onstop() When? Before the activity s state is changed to stop. What to do? Well Followed by onrestart() ondestroy() Properties This function s return is not guaranteed so abnormal termination can be done at anytime.

ondestroy() When? Before the activity s state is changed to inactive. What to do? Generally, undoing of oncreate function. Properties This function s return is not guaranteed so abnormal termination can be done at anytime.

onsaveinstancestate(bundle) When? When it is needed to save the state of the activity because of following abnormal termination(includes rotation of the screen). Before calling onpause function. What to do? Saving flowing(?) states to Bundle. e.g. Saving the state of very complex calculation. Followed by onpause()

onsaveinstancestate(bundle) Example of using Bundle @Override public void onsaveinstancestate(bundle b) { b.putint( 2^31 1", 2147483647); b.putstring( name", GodSiva ); super.onsaveinstancestate(b); }

onrestoreinstancestate(bundle) When? When the activity is being restored after abnormal termination(includes rotation of the screen). After calling oncreate and onstart functions, and Before calling onresume function. What to do? Restoring flowing(?) states from Bundle. Followed by onresume()

finish(), finishactivity() finish() Finishing the current activity itself. finishactivity() Finishing another activity. Both of the cases cause ondestroy callback function.