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