Unit I
Unit I
Development
with Android
Introduction
What is Android?
• A software platform and operating system for mobile devices
Google Android
Open Handset Alliance Members
Phones
HTC G1,
Droid, Motorola Droid (X)
Tattoo
Google Android
Android’s Context: Mobile Market Player$
Stakeholders:
• Mobile network operators want to
lock down their networks,
controlling and metering traffic.
• Device manufacturers want to
differentiate themselves with
features, reliability, and price
points.
• Software vendors want complete
access to the hardware to deliver
cutting-edge applications.
The Maturing Mobile Experience
• Tomorrow?
The Maturing Mobile Experience
Android vs. Competitors
Platform - The Android Software Stack
• Core Libraries
Providing most of the functionality available in the
core libraries of the Java language
APIs
Data Structures
Utilities
File Access
Network Access
Graphics
Etc @2010 Mihail L. Sichitiu 26
The Dalvik runtime is optimised for
mobile applications
Linux OS
Network Stack
Driver Model
Security
• The supplied device drivers include Display, Camera, Keypad,
WiFi, Flash Memory, Audio, and IPC (interprocess
communication).
Providing an abstraction layer between the H/W and the rest of the
S/W stack
@2010 Mihail L. Sichitiu 30
Platform
Network Connectivity
3G
Edge
Google Android
Software development
Development requirements
• Java
• Android SDK
Google Android
Software development
IDE and Tools
Android SDK
• Class Library
• Developer Tools
• Emulator and System Images
• Documentation and Sample Code
Google Android
Advantages
• The Android SDK is available for Windows, Mac and Linux, so you don’t
need to pay for new hardware to start writing applications.
• An SDK built on Java. If you’re familiar with the Java programming language,
you’re already halfway there.
• By distributing your application on Android Market, it’s available to hundreds of
thousands of users instantly. You’re not just limited to one store, because there are
alternatives, too. For instance, you can release your application on your own
blog. Amazon have recently been rumoured to be preparing their own
Android app store also.
• As well as the technical SDK documentation, new resources are being
published for Android developers as the platform gains popularity among both
users and developers.
Google Android
Application Building Blocks
• Activity
• IntentReceiver
• Service
• ContentProvider
Activities
Picasa
Contacts
“Pick photo”
GMail
Chat
Blogger
Blogger
Services
1
Tutorial
http://developer.android.com/resources/t
utorials/hello-world.html
http://mobiforge.com/developing/story/ge
tting-started-with-android-
development?dm_switcher=true
Android
Politeknik Elektronika Negeri Surabaya
2
Create a New Android Project
From Eclipse, select File > New > Android
Project.
Fill in the project details with the following
values:
Project name: HelloAndroid
Application name: Hello, Android
Package name: com.example.helloandroid (or
your own private namespace)
Create Activity: HelloAndroid
Click Finish
Android
Politeknik Elektronika Negeri Surabaya
3
Create a New
Android Project
Android
Politeknik Elektronika Negeri Surabaya
4
Create a New Android Project
Project name - the name of the project
Package name - the name of the package. This
name will be used as the package name in your
Java files. Package name must be fully qualified.
The convention is to use your company's domain
name in reverse order
Activity name - the name of the activity in your
Android application. In Android, think of an
activity as a screen containing some actions,
hence the name "activity"
Application name - the user-friendly name of the
application that will be displayed in the
Applications tab of the Android UI
Android
Politeknik Elektronika Negeri Surabaya
5
Package Content
All source code here Java code for our activity
Android Manifest
Android
Politeknik Elektronika Negeri Surabaya
6
the various fields when create a new
Android project
First, the src folder contains your Java source files. The HelloAndroid.java
file is the source file for the HelloAndroid activity you specified when you
created the project earlier.
The R.java file is a special file generated by the ADT to keep track of all
the names of views, constants, etc, used in your Android project. You
should not modify the content of this file as its content is generated
automatically by the ADT.
The Android Library contains a file named android.jar. This file contains all
the classes that you would use to program an Android application.
The res folder contains all the resources used by your Android application.
For example, the drawable folder contains a png image file that is used as
the icon for your application. The layout folder contains an XML file used to
represent the user interface of your Android application. The values folder
contains an XML file used to store a list of string constants.
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
Android
Politeknik Elektronika Negeri Surabaya
8
HelloAndroid.java
The basic unit of an Android application is an Activity.
An Activity displays the user interface of your application,
which may contain widgets like buttons, labels, text boxes,
etc
When the activity is loaded, the onCreate() event handler is
called.
The activity loads its UI from the XML file named main.xml.
This is represented by the constant named R.layout.main
(generated automatically by the Eclipse as you save your
project).
If you examine the main.xml file located in the res/layout
folder
Android
Politeknik Elektronika Negeri Surabaya
9
Run the Application
The Eclipse plugin makes it easy to run your applications:
Select Run > Run.
Select "Android Application".
Android
Politeknik Elektronika Negeri Surabaya
10
/res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/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="@string/hello"
/>
</LinearLayout>
Android
Politeknik Elektronika Negeri Surabaya
11
XML attributes
xmlns:android
This is an XML namespace declaration that tells the Android
tools that you are going to refer to common attributes
defined in the Android namespace. The outermost tag in
every Android layout file must have this attribute.
android:id
This attribute assigns a unique identifier to the TextView
element. You can use the assigned ID to reference this
View from your source code or from other XML resource
declarations.
android:layout_width
This attribute defines how much of the available width on
the screen this View should consume. In this case, it's the
only View so you want it to take up the entire screen, which
is what a value of "fill_parent" means.
Android
Politeknik Elektronika Negeri Surabaya
12
XML attributes
android:layout_height
This is just like android:layout_width, except that it refers
to available screen height.
android:text
This sets the text that the TextView should display. In this
example, you use a string resource instead of a hard-coded
string value. The hello string is defined in the
res/values/strings.xml file. This is the recommended
practice for inserting strings to your application, because it
makes the localization of your application to other
languages graceful, without need to hard-code changes to
the layout file.
Android
Politeknik Elektronika Negeri Surabaya
13
/res/values/strings.xml
In Android, the UI of each activity is represented using various
objects known as Views. You can create a view using code, or
more simply through the use of an XML file.
In this case, the UI Is represented using an XML file.
The <TextView> element represents a text label on the screen
while the <LinearLayout> element specifies how views should be
arranged.
Notice that the <TextView> element has an attribute named
android:text with its value set to "@string/hello".
The @string/hello refers to the string named hello defined in the
strings.xml file in the res/values folder.
Android
Politeknik Elektronika Negeri Surabaya
14
Modify strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello, Android! I am a string
resource!</string>
<string name="app_name">Hello, Android</string>
</resources>
Android
Politeknik Elektronika Negeri Surabaya
15
Run it !
Android
Politeknik Elektronika Negeri Surabaya
16
Modify the main.xml
Let's now modify the main.xml file. Add the following <Button> element:
Android
Politeknik Elektronika Negeri Surabaya
17
Run it !
Android
Politeknik Elektronika Negeri Surabaya
18
Construct UI
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
Android
Politeknik Elektronika Negeri Surabaya
19
Run it
Android
Politeknik Elektronika Negeri Surabaya
20
R class
In Eclipse, open the file named R.java (in the gen/ [Generated Java Files] folder).
The R.java file is a special file generated by the ADT to keep track of all the names of
views, constants, etc, used in your Android project. You should not modify the
content of this file as its content is generated automatically by the ADT
package com.example.helloandroid;
Android
Politeknik Elektronika Negeri Surabaya
21
AndroidManifest.xml
The AndroidManifest.xml file is an application configuration file
that contains detailed information about your application, such as
the number of activities you have in your application, the types of
permissions your application needs, the version information of
your application, and so on.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloandroid"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".HelloAndroid"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Android
Politeknik Elektronika Negeri Surabaya
22
Part 2-a
Android Environment
SDK
Victor Matos
Cleveland State University
1
2A. Android Environment: Eclipse & ADT
The Android Development Tools (ADT) plugin for Eclipse adds extensions
to the Eclipse IDE.
It allows you to create and debug Android applications easier and faster.
Advantages
1. It gives you access to other Android development tools from inside the
Eclipse IDE. For example:
• take screenshots,
• Debug / set breakpoints, and
• view thread and process information directly from Eclipse.
2. It provides a New Project Wizard, which helps you quickly create and
set up all of the basic files you'll need for a new Android application.
3. It automates and simplifies the process of building your Android
application.
4. It provides an Android code editor that helps you write valid XML for
your Android manifest and resource files.
5. It will export your project into a signed APK, which can be distributed
to users.
2
2A. Android Environment: Eclipse & ADT
3
2A. Android Environment: Eclipse & ADT
DDMS Perspective
Dalvik Debugging Monitoring System
4
2A. Android Environment: Eclipse & ADT
SETUP
Download the Android SDK – Installing on Windows, Linux, Mac OS
This page is taken from http://developer.android.com
If you're already using the Android SDK, you should update to the latest tools or platform using
the Android SDK and AVD Manager, rather than downloading a new SDK starter package.
Windows installer_r08-windows.exe
Mac OS X (intel) android-sdk_r08-mac_86.zip
Linux (i386) android-sdk_r08-linux_86.tgz
Here's an overview of the steps you must follow to set up the Android SDK:
1. Prepare your development computer and ensure it meets the system requirements.
2. Install the SDK starter package from the table above. (If you're on Windows, download the
installer for help with the initial setup.)
3. Install the ADT Plugin for Eclipse (if you'll be developing in Eclipse).
4. Add Android platforms and other components to your SDK.
5. Explore the contents of the Android SDK (optional).
To get started, download the appropriate package from the table above, then read the
guide to Installing the SDK.
5
2A. Android Environment: Eclipse & ADT
This page describes how to install the Android SDK and set up your development
environment for the first time.
Updating?
If you already have an Android SDK, use the Android SDK and AVD Manager tool
to install updated tools and new Android platforms into your existing
environment.
1. Make sure you have already installed the most recent JDK.
2. Make sure you have Eclipse installed on your computer (3.4 or newer is
recommended). Eclipse is available from: http://www.eclipse.org/downloads/
(For Eclipse 3.5 or newer, the "Eclipse Classic" version is recommended)
6
2A. Android Environment: Eclipse & ADT
If you downloaded the Windows installer (.exe file), run it now to install the SDK
Tools into a default location (which you can modify, usually the folder is:
c:/your-chosen-path/android-sdk-windows
Make a note of the name and location of the SDK directory on your system—you
will need to refer to the SDK directory later, when setting up the ADT plugin and
when using the SDK tools from command line.
If you used the Windows installer, when you complete the installation wizard, it
will launch the Android SDK and AVD Manager with a default set of platforms and
other components selected for you to install. Simply click Install to accept the
recommended set of components and install them.
You can launch the Android SDK and AVD Manager in one of the following ways:
From within Eclipse, select Window > Android SDK and AVD Manager.
On Windows, double-click the SDK Manager.ext file at the root of the Android
SDK directory.
On Mac or Linux, open a terminal and navigate to the tools/ directory in the
Android SDK, then execute: android
8
2A. Android Environment: Eclipse & ADT
Figure 1. The Android SDK and AVD Manager's Available Packages panel, which shows
the SDK components that are available for you to download into your environment.
9
2A. Android Environment: Eclipse & ADT
To simplify ADT setup, it is recommend installing the Android SDK prior to installing ADT.
The next step is to modify your ADT preferences in Eclipse to point to the
Android SDK directory:
Done!
11
2A. Android Environment: Eclipse & ADT
Android Virtual Devices (AVDs) are configurations of emulator options that let
you better model an actual device.
1. In Eclipse, choose Window > Android SDK and AVD Manager.
2. Select Virtual Devices in the left panel.
3. Click New.
4. The Create New AVD dialog appears.
5. Type the name of the AVD, such as “AVD23API9".
6. Choose a target (such as “Android 2.3 – API Level9”).
7. Optionally specify any additional settings
(SD, camera, trackball, ….) YES to all.
8. Click Create AVD.
12
2A. Android Environment: Eclipse & ADT
Android Virtual Devices (AVDs) are configurations of emulator options that let
you better model an actual device.
1. In Eclipse, choose Window > Android SDK and AVD Manager.
2. Select Virtual Devices in the left panel.
3. Click on an AVD
4. Click Start.
13
2A. Android Environment: Eclipse & ADT
A Final Step
This seems to be a transitional issue, and may go away in future releases. For
now, update the system’s PATH variable to recognize two folders inside your
android-sdk-winwows. The first is: tools and the second is platform-tools.
1. Windows > Start > Control Panel > System > Advanced > Environment
Variables > System Variables > PATH > Edit
2. Add references to the sub-folders mentioned above. In this example:
c:\android-sdk-windows\tools;C:\android-sdk-windows\platform-tools;
3. OK
14
Android Setup Videos
Appendix. Web resources available at
http://www.hometutorials.com/google-android.html
Five videos, a bit older (SDK1.0) but useful nonetheless.
15
Android Setup Tutorial
MAC OS Users
1. In a terminal window send the command: sudo su. You will act as the superuser.
1. Enter superuser’s password. After accepted, you will issue commands from a shell line.
2. Locate the file .profile and edit (pico, vi,…) its path contents as follows:
export PATH="/Users/myfolder/android-sdk-mac_86 3/tools":$PATH
16
Android Setup Tutorial
Appendix. Install Java
1. Go to http://developers.sun.com/downloads/
2. Expand choice Java SE.
3. Click on: Java SE (JDK) 6
4. From the list of choices select the most recent Java SE JDK (Update 14 in our case).
5. Click on the Download button
17
Android Setup Tutorial
Appendix. Install Java
1. On the next screen select Platform (Windows) and accept license agreement.
2. Hit the Continue button.
3. Check box: Java SE Development Kit 6u14 and click on the download (arrow) symbol
4. Save file to c:\
18
Android Setup Tutorial
Appendix. Install Java
5. Execute the downloaded file: jdk-6u14-windows-i586.exe
6. Click on Accept button to agree on licensing.
7. Note the Java folder location. Click on Next to complete installation.
19
Android Setup Tutorial
Appendix. Install Eclipse IDE
Eclipse is a multi-language software development
platform comprising an IDE and a plug-in system to
extend it. It can be used to develop applications in Java
and, by means of the various plug-ins, in other
languages (from Wikipedia)
1. Go to http://www.eclipse.org/downloads/.
2. Download the current version (Galileo at the time of
writing) and save it to drive C:\.
3. Unzip the compress file to your hard drive (c:\eclipse)
4. For convenience create a Shortcut to eclipse.exe and
place it on your Desktop.
20
Android Setup Tutorial
Appendix. Install Eclipse IDE
21
Android Setup Tutorial
Appendix. Creating an Android Project (made for 1.5)
Reference: http://developer.android.com/guide/developing/eclipse-adt.html
Hola Mundo
22
Android Setup Tutorial
Creating an Android Project
To create a new project:
1. Start Eclipse
2. Select File > New > Project.
3. Select Android > Android Project,
and click Next.
4. Enter Project name: AndHolaMundo.
5. Select Target Android 1.5.
6. Application name: Hola.
7. Package name: cis493.demo.
8. Create Activity: HolaMundo.
9. Min SDK Version: 3.
10. Click Finish.
23
Android Setup Tutorial
Creating an Android Project
Once you complete the New Project Wizard, ADT creates the following folders and
files in your new project:
• src/ Includes your stub Activity Java file. All other Java files for your application
go here.
• <Android Version>/ (e.g., Android 1.5/) Includes the android.jar file that your
application will build against.
• gen/ This contains the Java files generated by ADT, such as your R.java file and
interfaces created from AIDL files.
• assets/ This is empty. You can use it to store raw asset files.
• res/ A folder for your application resources, such as drawable files, layout files,
string values, etc.
• AndroidManifest.xml The Android Manifest for your project.
• default.properties This file contains project settings, such as the build target.
24
Android Setup Tutorial
Creating an Android
Project
Once you complete the New
Project Wizard, ADT creates the
following folders and files in your
new project:
25
Android Setup Tutorial
Creating an Android Project
26
Android Setup Tutorial
Creating an Android Project - Debugging
27
Android Setup Tutorial
Creating an Android Project
package matos.demo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
28
Android Setup Tutorial
Creating an Android Project
29
Android Setup Tutorial
Questions ?
30
Android Setup Tutorial
Summary of Android On-line Installation Resources
0. JAVA
http://www.dailymotion.com/video/x77uqg_google-android-emulator-tutorial-tr_tech
1. ECLIPSE
http://www.dailymotion.com/related/x77v5t_google-android-eclipse-adt-tutorial_tech/video/x77usr_google-android-eclipse-tutorial-tra_tech
2. ANDROID-SDK
Android ADT Eclipse Plug-in link: https://dl-ssl.google.com/android/eclipse/
http://www.dailymotion.com/related/x77v5t_google-android-eclipse-adt-tutorial_tech/video/x77uou_google-android-sdk-emulator-tutoria_tech
3. ECLIPSE-PLUGIN
http://www.dailymotion.com/related/x77usr_google-android-eclipse-tutorial-tra_tech/video/x77v5t_google-android-eclipse-adt-
tutorial_tech?from=rss
5. DROID_DRAW
http://www.droiddraw.org
Appendix A.
Android Virtual Devices
An AVD tells the emulator what kind of device it is suppose to impersonate.
Currently there are a few of these targets, such as:
Target Description
Level
4 Identifies an Android 1.6 device that has Google Maps support
[mostly all new Android devices after 2008]
32
Android Setup Tutorial
Appendix A. Cont
Android SDK Targets (2.x and newer versions)
You may use the UI app to inspect available components and download target platforms.
Downloading
This is a three-steps operation. First install the (empty) SDK shell as indicated above (download and
unzip). Second update the path system variable to include the path to: android-sdk-windows\tools.
Third: access the repository, select and download the specific targets.
How?
At the console prompt type in the command
C:> android
33
Part 3
Android
Application’s Life Cycle
Victor Matos
Cleveland State University
Android Developers
http://developer.android.com/index.html
3. Android – Application's Life Cycle
Android Applications
An application consists of one or more components that are
defined in the application's manifest file. A component can be one
of the following:
1. An Activity
2. A Service
3. A broadcast receiver
4. A content provider
2
3. Android – Application's Life Cycle
Android Applications
1. Activity
An activity usually presents a single visual user interface from which a number of
actions could be performed.
Altough activities work together to form a cohesive user interface, each activity
is independent of the others.
Typically, one of the activities is marked as the first one that should be presented
to the user when the application is launched.
Android Applications
2. Service
A service doesn't have a visual user interface, but rather runs in the background
for an indefinite period of time.
It's possible to connect to (bind to) an ongoing service (and start the service if it's
not already running).
While connected, you can communicate with the service through an interface
that the service exposes.
Android Applications
3. Broadcast receiver
A broadcast receiver is a component that does nothing but receive and react to
broadcast announcements.
Many broadcasts originate in system code (eg. “you got mail“) but any other
applications can also initiate broadcasts.
Broadcast receivers do not display a user interface. However, they may start an
activity in response to the information they receive, or - as services do - they
may use the notification manager to alert the user.
Android Applications
4. Content provider
The content provider implements a standard set of methods that enable other
applications to retrieve and store data of the type it controls.
However, applications do not call these methods directly. Rather they use a
content resolver object and call its methods instead. A content resolver can talk
to any content provider; it cooperates with the provider to manage any
interprocess communication that's involved.
Reference: Friedger Müffke (friedger@openintents.org)
6
3. Android – Application's Life Cycle
Android Applications
Every Android application runs in its own process
(with its own instance of the Dalvik virtual machine).
7
3. Android – Application's Life Cycle
1. it is no longer needed, OR
2. the system needs to reclaim its memory for use by other
applications.
8
3. Android – Application's Life Cycle
1. the parts of the application that the system knows are running,
2. how important these things are to the user, and
3. how much overall memory is available in the system.
9
3. Android – Application's Life Cycle
Component Lifecycles
Application components have a lifecycle
10
3. Android – Application's Life Cycle
Activty Stack
• Activities in the system are managed as an activity stack.
• If the user presses the Back Button the next activity on the
stack moves up and becomes active.
11
3. Android – Application's Life Cycle
Activity Stack
New Activity Running Activity
Last Running
Activity
Activity n-1
Activity Stack ...
Previous Activity 3
Activities Removed to
Activity 2 free resources
Activity 1
12
3. Android – Application's Life Cycle
1. It is active or running
2. It is paused or
3. It is stopped .
13
3. Android – Application's Life Cycle
This is the activity that is the focus for the user's actions.
14
3. Android – Application's Life Cycle
That is, another activity lies on top of it and that new activity either is
transparent or doesn't cover the full screen.
A paused activity is completely alive (it maintains all state and member
information and remains attached to the window manager), but can be
killed by the system in extreme low memory situations.
15
3. Android – Application's Life Cycle
16
3. Android – Application's Life Cycle
Application’s
Life Cycle
17
3. Android – Application's Life Cycle
18
3. Android – Application's Life Cycle
All activities must implement onCreate() to do the initial setup when the
object is first instantiated.
Many activities will also implement onPause() to commit data changes and
otherwise prepare to stop interacting with the user.
19
3. Android – Application's Life Cycle
Application’s Lifetime
The seven transition methods define the entire lifecycle of an activity.
An activity does all its initial setup of "global" state in onCreate(), and
releases all remaining resources in onDestroy().
20
3. Android – Application's Life Cycle
Visible Lifetime
The visible lifetime of an activity happens between a call to onStart() until a
corresponding call to onStop().
During this time, the user can see the activity on-screen, though it may not
be in the foreground and interacting with the user.
The onStart() and onStop() methods can be called multiple times, as the
activity alternates between being visible and hidden to the user.
Between these two methods, you can maintain resources that are needed
to show the activity to the user.
21
3. Android – Application's Life Cycle
Foreground Lifetime
The foreground lifetime of an activity happens between a call to
onResume() until a corresponding call to onPause().
During this time, the activity is in front of all other activities on screen and is
interacting with the user.
22
3. Android – Application's Life Cycle
Method: onCreate()
23
3. Android – Application's Life Cycle
Method: onRestart()
• Called after the activity has been stopped, just prior to it being
started again.
• Always followed by onStart()
Method: onStart()
24
3. Android – Application's Life Cycle
Method: onResume()
1. Called just before the activity starts interacting with the user.
2. At this point the activity is at the top of the activity stack, with
user input going to it.
3. Always followed by onPause().
25
3. Android – Application's Life Cycle
Method: onPause()
26
3. Android – Application's Life Cycle
Method: onStop()
27
3. Android – Application's Life Cycle
Method: onDestroy()
28
3. Android – Application's Life Cycle
29
3. Android – Application's Life Cycle
Assign a name to your set of preferences if you want to share them with other
components in the same application, or use Activity.getPreferences() with no
name to keep them private to the calling activity.
Example
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
31
3. Android – Application's Life Cycle
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
32
3. Android – Application's Life Cycle
txtToDo.setText(msg);
33
3. Android – Application's Life Cycle
@Override
protected void onRestart() {
super.onRestart();
Toast.makeText(this, "onRestart", 1).show();
}
@Override
protected void onResume() {
super.onResume();
Toast.makeText(this, "onResume", 1).show();
}
35
3. Android – Application's Life Cycle
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Toast.makeText(this, "onDestroy", 1).show();
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
Toast.makeText(this, "onStop", 1).show();
} 36
3. Android – Application's Life Cycle
38
3. Android – Application's Life Cycle
/*
protected void onRestoreInstanceState(Bundle savedInstanceState)
This method is called after onStart() when the activity is being re-initialized
from a previously saved state.
The default implementation of this method performs a restore of any view state
that had previously been frozen by onSaveInstanceState(Bundle).
*/
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Toast.makeText(getBaseContext(),
"onRestoreInstanceState ...BUNDLING",
Toast.LENGTH_LONG).show();
}
39
3. Android – Application's Life Cycle
/*
protected void onSaveInstanceState(Bundle outState)
40
3. Android – Application's Life Cycle
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Toast.makeText(getBaseContext(),
"onSaveInstanceState ...BUNDLING",
Toast.LENGTH_LONG).show();
} // onSaveInstanceState
}//LyfeCicleDemo
41
3. Android – Application's Life Cycle
42
3. Android – Application's Life Cycle
Questions ?
45