LECTURE NOTES OF APPLICATION ACTIVITIES

Similar documents
UNDERSTANDING ACTIVITIES

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

Overview of Activities

Android Activities. Akhilesh Tyagi

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming

Lab 1: Getting Started With Android Programming

States of Activities. Active Pause Stop Inactive

Embedded Systems Programming - PA8001

Real-Time Embedded Systems

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

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

Vienos veiklos būsena. Theory

Activities. Repo:

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

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

LifeStreet Media Android Publisher SDK Integration Guide

FRAGMENTS.

Minds-on: Android. Session 2

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

ECOM 5341 Mobile Computing(Android) Eng.Ruba A. Salamah

Introduction To Android

Configuring the Android Manifest File

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

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

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

8Messaging SMS MESSAGING.

Group B: Assignment No 8. Title of Assignment: To verify the operating system name and version of Mobile devices.

12 Publishing Android Applications

EMBEDDED SYSTEMS PROGRAMMING Application Basics

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Lifecycle-Aware Components Live Data ViewModel Room Library

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

CMSC436: Fall 2013 Week 3 Lab

Application Fundamentals

COPYRIGHTED MATERIAL. 1Getting Started with Android Programming

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

Android Fundamentals - Part 1

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

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

UI Fragment.

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

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

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

Android Application Development. By : Shibaji Debnath

Using Eclipse for Android Development

Intents & Intent Filters. codeandroid.org

COMP4521 EMBEDDED SYSTEMS SOFTWARE

Computer Science E-76 Building Mobile Applications

Android framework overview Activity lifecycle and states

Activities and Fragments

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

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

Android Ecosystem and. Revised v4presenter. What s New

Lifecycle Callbacks and Intents

Understanding Application

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

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Android Application Development

Gauthier Picard. Ecole Nationale Supérieure des Mines

Introduction to Android development

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

Applications. Marco Ronchetti Università degli Studi di Trento

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

Android Services. Victor Matos Cleveland State University. Services

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

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

COLLEGE OF ENGINEERING, NASHIK-4

Programming Mobile Applications with Android Lab2

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

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

Building MyFirstApp Android Application Step by Step. Sang Shin Learn with Passion!

Multiple Activities. Many apps have multiple activities

CE881: Mobile & Social Application Programming

App Development for Android. Prabhaker Matet

Xin Pan. CSCI Fall

CS 4330/5390: Mobile Application Development Exam 1

ANDROID APP DEVELOPMENT

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

Android Workshop: Model View Controller ( MVC):

Security model. Marco Ronchetti Università degli Studi di Trento

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

COSC 3P97 Mobile Computing

Android Beginners Workshop

Creating Android Applications

This document providesanoverview ofthestepsrequired to implement an android app which will call the ACH android SDK.

Introduction to Android

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Android

Midterm Examination. CSCE 4623 (Fall 2017) October 20, 2017

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

Learn about Android Content Providers and SQLite

Mobile Computing Practice # 2c Android Applications - Interface

Login with Amazon. Getting Started Guide for Android apps

University of Waterloo Midterm Examination

Manifest.xml. Activity.java

University of Waterloo Midterm Examination Solutions

Android Programmierung leichtgemacht. Lars Vogel

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

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

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

Transcription:

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 APPLICATION Components Activity Service Broadcast receiver Content provider Typically, applications have one or more activities; and the main purpose of an activity is to interact with the user. From the moment an activity appears on the screen to the moment it is hidden, it goes through a number of stages, known as an activity s life cycle. Understanding the life cycle of an activity is vital to ensuring that your application works correctly. Apart from activities, another unique concept in Android is that of an intent. An intent is basically the glue that enables different activities from different applications to work together seamlessly, ensuring that tasks can be performed as though they all belong to one single application.

The Topics 1. The activity class 2. The task backstack 3. The activity life cycle 4. Starting activities 5. Handling configuration changes

The Activity The activity Provides a visual interface for user interaction Each activity typically supports one focused thing a user can do, such as Viewing an email message Showing a login screen Note : Android supports navigation in several ways: 1. Tasks 2. The task backstack 3. Suspending & resuming activities

1. A Task is a set of related Activities: These related activities don t have to be part of the same application Most tasks start at the home screen See: http://developer.android.com/guide/topics/fundamentals/tasksand-back-stack.html 2. The Task Backstack When an Activity is launched, it goes on top of the backstack When the Activity is destroyed, it is popped off the backstack

UNDERSTANDING ACTIVITIES To create an activity. To create an activity, you create a Java class that extends the Activity base class: package net.learn2develop.activity101; import android.app.activity; import android.os.bundle; public class Activity101Activity extends Activity { /** Called when the activity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); } } Your activity class loads its UI component using the XML file defined in your res/layout folder. In this example, you would load the UI from the main.xml fi le: setcontentview (R.layout.main); Every activity you have in your application must be declared in your AndroidManifest.xml fi le, like this:

Declare of each Activaty in application <?xml version= 1.0 encoding= utf-8?> <manifest xmlns:android= http://schemas.android.com/apk/res/android package= net.learn2develop.activity101 android:versioncode= 1 android:versionname= 1.0 > <uses-sdk android:minsdkversion= 14 /> <application android:icon= @drawable/ic_launcher android:label= @string/app_name > <activity android:label= @string/app_name android:name=.activity101activity > <intent-filter > <action android:name= android.intent.action.main /> <category android:name= android.intent.category.launcher /> </intent-filter> </activity> </application> </manifest>

Declare of each Activaty in application Within the definition for this activity, there is an element named <intent-filter>: The action for the intent filter is named android.intent.action.main to indicate that this activity serves as the entry point for the application. The category for the intent-filter is named android.intent.category.launcher to indicate that the application can be launched from the device s launcher icon. The Activity base class defines a series of events that govern the life cycle of an activity. Activity class defines the following events: oncreate() Called when the activity is first created onstart() Called when the activity becomes visible to the user onresume() Called when the activity starts interacting with the user onpause() Called when the current activity is being paused and the previous activity is being resumed onstop() Called when the activity is no longer visible to the user ondestroy() Called before the activity is destroyed by the system (either manually or by the system to conserve memory) onrestart() Called when the activity has been stopped and is restarting again

The Activity Life Cycle

The Activity Life Cycle

The Activity Life Cycle

The Activity Life Cycle

Functions OnCreate() Called when Activity is created Sets up Initial state Call super.oncreate() Set the Activity s content view Retain references to UI views as necessary Configure views as necessary Called if the Activity has been stopped and is about to be started again Typical actions Special processing needed only after having been stopped

Recall of some activities protected void oncreate (Bundle savedinstancestate) protected void onstart() protected void onresume() protected void onpause() protected void onrestart() protected void onstop() protected void ondestroy() Example: apply the Map Location on the class room. <activity android:name=".myactivity " android:configchanges=" "orientation screensize keyboardhidden >

Configuration Changes Activity restarting should be fast If necessary you can: 1. Retain an Object containing important state information during a configuration change 2. Manually handle the configuration change <activity android:name=".myactivity "android:configchanges=" "orientation screensize keyboardhidden >