ACTIVITY LIFECYCLE IN KOTLIN

Working of Activity Lifecycle
when application open
When we move the application to the background
Application is in the foreground
We close the application
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

Log.i("onCreate()","onCreate Called") }

override fun onStart() {
super.onStart()
Log.i("onStart()","onStart Called") }

override fun onRestart() {
super.onRestart()
Log.i("onRestart()","onRestart Called") }

override fun onPause() {
super.onPause()
Log.i("onPause()","onPause Called")
}

override fun onResume() {
super.onResume()
Log.i("onResume()","onResume Called") }

override fun onStop() {
super.onStop()
Log.i("onStop()","onStop Called") }

override fun onDestroy() {
super.onDestroy()
Log.i("onDestroy()","onDestroy Called")
}
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Build an Android App with Flutter: A Beginner’s Guide for Windows Users

Flutter Beautiful Expanded

Launching Splash Screen in Android Different Ways

Galaxy Shooter 2D — Debuffs

How to save List of Data in Table Column in Room Using Type Converter & Gson

VIPER Architecture Tutorial (Android/Kotlin)

Android VIPER Architecture Tutorial (Kotlin),Pankaj jangid,VIPER for android

How to use NFC in Android

Things I learnt while developing shareit clone of Android app

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tushar Jha

Tushar Jha

More from Medium

Android Paintflags Configuration, Explained

Network call with kotlin coroutines

Handling project dependencies using type-safe project accessor

Make a simple RecyclerView in Android with Kotlin