Sat. Apr 20th, 2024

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")
    }
}

By Rajashekar

I’m (Rajashekar) a core Android developer with complimenting skills as a web developer from India. I cherish taking up complex problems and turning them into beautiful interfaces. My love for decrypting the logic and structure of coding keeps me pushing towards writing elegant and proficient code, whether it is Android, PHP, Flutter or any other platforms. You would find me involved in cuisines, reading, travelling during my leisure hours.

Leave a Reply

Your email address will not be published. Required fields are marked *