deyanmalinov

Android / Activity State Changes

Jun 13th, 2021 (edited)
626
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---MainActivity.java---
  2.  
  3. package com.example.myfirstapplication;
  4.  
  5. import android.os.Bundle;
  6. import android.util.Log;
  7. import android.widget.Toast;
  8. import androidx.appcompat.app.AppCompatActivity;
  9.  
  10. public class MainActivity extends AppCompatActivity {
  11.     String msg = "";
  12.  @Override
  13.     public void onCreate(Bundle savedInstanceState) {
  14.         super.onCreate(savedInstanceState);
  15.         setContentView((int) R.layout.activity_main);
  16.         Toast.makeText(this, "onCreate", 0).show();
  17.         Log.d(this.msg, "onCreate");
  18.     }
  19.  @Override
  20.     public void onStart() {
  21.         super.onStart();
  22.         Toast.makeText(this, "onStart", 0).show();
  23.         Log.d(this.msg, "onStart");
  24.     }
  25.  @Override
  26.     public void onResume() {
  27.         super.onResume();
  28.         Toast.makeText(this, "onResume", 0).show();
  29.         Log.d(this.msg, "onResume");
  30.     }
  31.  @Override
  32.     public void onPause() {
  33.         super.onPause();
  34.         Toast.makeText(this, "onPause", 0).show();
  35.         Log.d(this.msg, "onPause");
  36.     }
  37.  @Override
  38.     public void onStop() {
  39.         super.onStop();
  40.         Toast.makeText(this, "onStop", 0).show();
  41.         Log.d(this.msg, "onStop");
  42.     }
  43.  @Override
  44.     public void onDestroy() {
  45.         Toast.makeText(this, "onDestroy", 0).show();
  46.         Log.d(this.msg, "onDestroy");
  47.         super.onDestroy();
  48.     }
  49. }
RAW Paste Data