0% found this document useful (0 votes)
18 views4 pages

Android Activity Lifecycle Overview

This document discusses an Android activity lifecycle lab assignment. It includes the Java code for a MainActivity class that implements methods corresponding to the activity lifecycle phases like onCreate(), onStart(), onResume(), etc. Each method displays a toast notification of the current phase. It also includes the XML layout code for the activity's user interface containing a simple text view.

Uploaded by

Aisya Zuhudi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Android Activity Lifecycle Overview

This document discusses an Android activity lifecycle lab assignment. It includes the Java code for a MainActivity class that implements methods corresponding to the activity lifecycle phases like onCreate(), onStart(), onResume(), etc. Each method displays a toast notification of the current phase. It also includes the XML layout code for the activity's user interface containing a simple text view.

Uploaded by

Aisya Zuhudi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SKR4307- Mobile Application

Lab 3a - Android Activity Lifecycle

By: Nurul Aisyah Binti Ahmad Zuhudi

Matric Number: 193904


[Link]
package [Link].lab3a;

import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
[Link]([Link],"ON CREATE",
Toast.LENGTH_SHORT).show();
}

@Override
protected void onStart() {
[Link]();
[Link]([Link],"ON START",
Toast.LENGTH_SHORT).show();
}

@Override
protected void onResume() {
[Link]();
[Link]([Link],"ON RESUME",
Toast.LENGTH_SHORT).show();

@Override
protected void onPause() {
[Link]();
[Link]([Link],"ON PAUSE",
Toast.LENGTH_SHORT).show();

@Override
protected void onStop() {
[Link]();
[Link]([Link],"ON STOP",
Toast.LENGTH_SHORT).show();

@Override
protected void onRestart() {
[Link]();
[Link]([Link],"ON RESTART",
Toast.LENGTH_SHORT).show();

@Override
protected void onDestroy() {
[Link]();
[Link]([Link],"ON DESTROY",
Toast.LENGTH_SHORT).show();

}
}

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</[Link]>
Expected Results

You might also like