You are on page 1of 11

HOME APPLICATION DEVELOPMENT &

EMERGING TECHNOLOGIES
Outline / Introduction
Your business tag line here.

Objective

life cycle diagram

Callback Method 1
COURSE MODULE 5:CALL BACK METHODS
Callback Method 2

Callback Method 3 SUBJECT CODE: CC106

AndroidManifest.xml SUBJECT TITLE: APPLICATION DEVELOPMENT AND


EMERGING TECHNOLOGIES
Run our modified

Online Videos and SUBJECT DESCRIPTION: Development of applications


using web, mobile, and emerging technologies with
Activities/Assignments emphasis on requirements management, interface
design, usability, testing deployment, including
ethical and legal considerations.

UNITS: THREE (3)

NO. OF HRS PER WEEK: 5HRS. LECTURE: 2HRS.


LABORATORY: 3HRS. WEEK 5:
APPLICATION
DEVELOPMENT &
EMERGING

To contact us:

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527

Page 1
Email:
HOME
WEEK 5: CALL BACK METHODS
Outline / Introduction Application Development & Emerging Technologies

Objective

life cycle diagram


COURSE MODULE 5:CALL BACK METHODS
Callback Method 1
Course Outline
Callback Method 2

1. Callback Method and Description


Callback Method 3
2. Run our modified Hello World! Application
AndroidManifest.xml
Introduction
Run our modified
An activity represents a single
Online Videos and
screen with a user interface just
like window or frame of <Hello World>

Activities/Assignments
Java.Android activity is the <I’AM ANDROID>
subclass of ContextThemeWrapper
class. Android system initiates
its program with in an Activity
starting with a call on
onCreate() callback method. There
is a sequence of callback methods
that start up an activity and a
sequence of callback methods that
tear down an activity as shown in
the below Activity life cycle
diagram:

Page 2
HOME
TE
W IE
TKLE5: CALL BACK METHODS
Outline / Introduction Application Development & Emerging Technologies

Objective

life cycle diagram

Callback Method 1
OBJECTIVES
Callback Method 2 Application Development & Emerging Technologies

Callback Method 3
1. At the end of the period the students should be
AndroidManifest.xml able to know what is Android, development and its
API Level to define version of the platform.
Run our modified

Online Videos and


Introduction

Activities/Assignments 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, led by
Google, and other companies.

Android offers a unified approach to application


development for mobile devices which means
developers need only develop for Android, and
their applications should be able to run on
different devices powered by Android.

The first beta version of the Android Software


Development Kit (SDK) was released by Google in
2007 where as the first commercial version,
Android 1.0, was released in September 2008.

On June 27, 2012, at the Google I/O conference,


Google announced the next Android version, 4.1
Jelly Bean. Jelly Bean is an incremental update,
with the primary aim of improving the user
interface, both in terms of functionality and
performance.

Page 3

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527
TE
W IE
TKLE5: CALL BACK METHODS
HOME
Application Development & Emerging Technologies
Outline / Introduction

Objective

life cycle diagram ACTIVITY LIFE CYCLE


Callback Method 1
DIAGRAM:
Application Development & Emerging Technologies
Callback Method 2

Callback Method 3

AndroidManifest.xml

Run our modified

Online Videos and

Activities/Assignments

The Activity class defines the following call


backs i.e. events. You don't need to implement
all the callbacks methods. However, it's
important that you understand each one and
implement those that ensure your app behaves
the way users expect.
Page 4

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527
TE
W IE
TKLE5: CALL BACK METHODS
HOME
Application Development & Emerging Technologies
Outline / Introduction

Objective

life cycle diagram CALLBACK METHOD AND


Callback Method 1 DESCRIPTION
Application Development & Emerging Technologies
Callback Method 2

Callback Method 3

AndroidManifest.xml

Run our modified

Online Videos and

Activities/Assignments

Example that shows Android application


activity life cycle. Follow the steps that
will modify the Android application we
created in Hello World Example:

Page 4

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527
TE
W IE
TKLE5: CALL BACK METHODS
HOME
Application Development & Emerging Technologies
Outline / Introduction

Objective

life cycle diagram CALLBACK METHOD AND


Callback Method 1
DESCRIPTION
Application Development & Emerging Technologies
Callback Method 2

Callback Method 3

AndroidManifest.xml

Run our modified

Online Videos and

Activities/Assignments

Below is the content of the modified main activity file src/com.example.helloworld/


MainActivity.java. This file includes each of the fundamental life cycle methods. The Log.d() method has been used to
generate log messages:

package com.example.helloworld;

import android.os.Bundle; import android.app.Activity; import android.util.Log;

public class MainActivity extends Activity {


String msg = "Android : ";

/** Called when the activity is first created. */


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(msg, "The onCreate() event");
}

/** Called when the activity is about to become visible. */


@Override
protected void onStart() {
super.onStart();
Log.d(msg, "The onStart() event");
}

/** Called when the activity has become visible. */


@Override
protected void onResume() {
super.onResume();
Log.d(msg, "The onResume() event");
}
Page 4

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527
TE
W IE
TKLE5: CALL BACK METHODS
HOME
Application Development & Emerging Technologies
Outline / Introduction

Objective

life cycle diagram CALLBACK METHOD AND


Callback Method 1
DESCRIPTION
Application Development & Emerging Technologies
Callback Method 2
/** Called when another activity is taking focus. */
Callback Method 3 @Override
protected void onPause() {
super.onPause();
AndroidManifest.xml Log.d(msg, "The onPause() event");
}
Run our modified /** Called when the activity is no longer visible. */
@Override
protected void onStop() {
Online Videos and super.onStop();
Log.d(msg, "The onStop() event");
Activities/Assignments }
/** Called just before the activity is destroyed. */
@Override
public void onDestroy() {
super.onDestroy();
Log.d(msg, "The onDestroy() event");
}
}

Page 4

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527
TE
W IE
TKLE5: CALL BACK METHODS
HOME
Application Development & Emerging Technologies
Outline / Introduction

Objective

life cycle diagram

Callback Method 1
ANDROIDMANIFEST.XML
Application Development & Emerging Technologies
Callback Method 2
Every activity you define for your application
Callback Method 3 must be declared in your AndroidManifest.xml
file and the main activity for your app must be declared
AndroidManifest.xml in the manifest with an <intent-filter> that includes
the MAIN action and LAUNCHER category as follows:
Run our modified

<?xml version="1.0" encoding="utf-8"?>


Online Videos and
<manifest xmlns:android="http://schemas.android.com/apk/
Activities/Assignments res/android"
package="com.example.tutorialspoint7.myapplication">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" /
>

<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Note:
If either the MAIN action or LAUNCHER category are not
declared for one of your activities, then your app icon
will not appear in the Home screen's list of apps.

Page 4

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527
TE
W IE
TKLE5: CALL BACK METHODS
HOME
Application Development & Emerging Technologies
Outline / Introduction

Objective

life cycle diagram RUN OUR MODIFIED HELLO


Callback Method 1
WORLD! APPLICATION
Application Development & Emerging Technologies
Callback Method 2
Run our modified Hello World! application
Callback Method 3
Click Run icon from the toolbar. Android studio installs
AndroidManifest.xml the app on your AVD and starts it and if everything is
fine with your setup and application, it will display
Run our modified
Emulator window and you should see following log
messages in LogCat window in Android studio:
Online Videos and

Activities/Assignments

Click lock screen button on the Android emulator and it


will generate following events messages in LogCat window
in android studio:

Unlock your screen on the Android emulator and it will


generate following events messages in LogCat window in
Android studio:

Click Back button on the Android emulator and it will


generate following events messages in LogCat window in
Android studio and this completes the Activity Life
Cycle for an Android Application:

Page 4

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527
TE
W IE
TKLE5: CALL BACK METHODS
HOME
Application Development & Emerging Technologies
Outline / Introduction

Objective

life cycle diagram SUGGESTED ONLINE VIDEOS


Callback Method 1
AND READINGS
Application Development & Emerging Technologies
Callback Method 2
1. In YouTube, a video created by Android Developer:
Callback Method 3
https://www.youtube.com/watch?v=SY1uz2ugIPw
AndroidManifest.xml
2. Den of Developers:
Run our modified

https://denofdevelopers.com/android-activity-
Online Videos and
lifecycle-exercise/
Activities/Assignments

Page 4

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527
TE
W IE
TKLE5: CALL BACK METHODS
HOME
Application Development & Emerging Technologies
Outline / Introduction

Objective

life cycle diagram

Callback Method 1
ACTIVITIES AND ASSIGNMENTS
Application Development & Emerging Technologies
Callback Method 2

Callback Method 3
Activity 1
AndroidManifest.xml
1. In activities from previous lesson, implement
Run our modified and define the function of callback method.

Online Videos and

Activities/Assignments

Page 4

Manlunas Street, Piccio Garden, Villamor Air Base,


Pasay City 1309 Metro Manila
Landline:
+63 (2) 8 425 5291
+63 (2) 8 513 0849
+63 (2) 8 853 5127
+63 (2) 401 5527

You might also like