Create application for demonstration of android activity life cycle

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:id="@+id/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>

MainActivity.java

package com.example.helloworld;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

TextView textView;
String text;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

textView = findViewById(R.id.textView);
text = textView.getText().toString();
text = text + "\n onCreate Method";
textView.setText(text);
}
@Override
protected void onStart() {
super.onStart();
text = textView.getText().toString();
text = text + "\n onStart Method";
textView.setText(text);
}
@Override
protected void onResume() {
super.onResume();
text = textView.getText().toString();
text = text + "\n onResume Method";
textView.setText(text);
}
@Override
protected void onPause() {
super.onPause();
text = textView.getText().toString();
text = text + "\n onPause Method";
textView.setText(text);
}
@Override
protected void onStop() {
super.onStop();
text = textView.getText().toString();
text = text + "\n onStop Method";
textView.setText(text);
}
@Override
protected void onRestart() {
super.onRestart();
text = textView.getText().toString();
text = text + "\n onRestart Method";
textView.setText(text);
}
@Override
protected void onDestroy() {
super.onDestroy();
text = textView.getText().toString();
text = text + "\n onDestroy Method";
textView.setText(text);
}
}

Output