mainactivity.kt
package com.example.lifecycle
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Toast
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Toast.makeText(applicationContext,"We are in onCreate Method",Toast.LENGTH_LONG).show()
Log.i("Lifecycle","We are in onCreate Method")
}
override fun onStart(){
super.onStart()
Toast.makeText(applicationContext,"We are in onStart Method",Toast.LENGTH_LONG).show()
Log.i("Lifecycle","We are in onStart Method")
}
override fun onResume(){
super.onResume()
Toast.makeText(applicationContext,"We are in onResume Method",Toast.LENGTH_LONG).show()
Log.i("Lifecycle","We are in onResume Method")
}
override fun onPause() {
super.onPause()
Toast.makeText(applicationContext,"We are in onPause Method",Toast.LENGTH_LONG).show()
Log.i("Lifecycle","We are in onPause Method")
}
override fun onStop() {
super.onStop()
Toast.makeText(applicationContext,"We are in onStop Method",Toast.LENGTH_LONG).show()
Log.i("Lifecycle","We are in onStop Method")
}
override fun onDestroy() {
super.onDestroy()
Toast.makeText(applicationContext,"We are in onDestroy Method",Toast.LENGTH_LONG).show()
Log.i("Lifecycle","We are in onDestroy Method")
}
override fun onRestart() {
super.onRestart()
Toast.makeText(applicationContext,"We are in onRestart Method",Toast.LENGTH_LONG).show()
Log.i("Lifecycle","We are in onRestart Method")
}
}