Lab 3a
Lab 3a
Lab 3a
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(MainActivity.this,"ON CREATE",
Toast.LENGTH_SHORT).show();
}
@Override
protected void onStart() {
super.onStart();
Toast.makeText(MainActivity.this,"ON START",
Toast.LENGTH_SHORT).show();
}
@Override
protected void onResume() {
super.onResume();
Toast.makeText(MainActivity.this,"ON RESUME",
Toast.LENGTH_SHORT).show();
@Override
protected void onPause() {
super.onPause();
Toast.makeText(MainActivity.this,"ON PAUSE",
Toast.LENGTH_SHORT).show();
@Override
protected void onStop() {
super.onStop();
Toast.makeText(MainActivity.this,"ON STOP",
Toast.LENGTH_SHORT).show();
@Override
protected void onRestart() {
super.onRestart();
Toast.makeText(MainActivity.this,"ON RESTART",
Toast.LENGTH_SHORT).show();
@Override
protected void onDestroy() {
super.onDestroy();
Toast.makeText(MainActivity.this,"ON DESTROY",
Toast.LENGTH_SHORT).show();
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
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" />
</androidx.constraintlayout.widget.ConstraintLayout>
Expected Results