Created
April 25, 2025 11:52
-
-
Save mikkipastel/22f030764c1aeacb3973474d74a4188c to your computer and use it in GitHub Desktop.
show toast to learn activity lifecycle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mikkipastel.example | |
import android.content.Intent | |
import android.os.Bundle | |
import android.util.Log | |
import android.widget.Toast | |
import androidx.appcompat.app.AppCompatActivity | |
import com.mikkipastel.mlbarcode.databinding.ActivityMainBinding | |
class MainActivity: AppCompatActivity() { | |
private lateinit var binding: ActivityMainBinding | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
binding = ActivityMainBinding.inflate(layoutInflater) | |
setContentView(binding.root) | |
Toast.makeText(this, "MainActivity: onCreate", Toast.LENGTH_SHORT).show() | |
} | |
override fun onStart() { | |
super.onStart() | |
Toast.makeText(this, "MainActivity: onStart", Toast.LENGTH_SHORT).show() | |
} | |
override fun onResume() { | |
super.onResume() | |
Toast.makeText(this, "MainActivity: onResume", Toast.LENGTH_SHORT).show() | |
} | |
override fun onPause() { | |
super.onPause() | |
Toast.makeText(this, "MainActivity: onPause", Toast.LENGTH_SHORT).show() | |
} | |
override fun onStop() { | |
super.onStop() | |
Toast.makeText(this, "MainActivity: onStop", Toast.LENGTH_SHORT).show() | |
} | |
override fun onRestart() { | |
super.onRestart() | |
Toast.makeText(this, "MainActivity: onRestart", Toast.LENGTH_SHORT).show() | |
} | |
override fun onDestroy() { | |
super.onDestroy() | |
Toast.makeText(this, "MainActivity: onDestroy", Toast.LENGTH_SHORT).show() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mikkipastel.example | |
import android.os.Bundle | |
import android.util.Log | |
import android.widget.Toast | |
import androidx.appcompat.app.AppCompatActivity | |
import com.mikkipastel.example.databinding.ActivitySecondBinding | |
class SecondActivity: AppCompatActivity() { | |
private lateinit var binding: ActivitySecondBinding | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
binding = ActivitySecondBinding.inflate(layoutInflater) | |
Toast.makeText(this, "SecondActivity: onCreate", Toast.LENGTH_SHORT).show() | |
} | |
override fun onStart() { | |
super.onStart() | |
Toast.makeText(this, "SecondActivity: onStart", Toast.LENGTH_SHORT).show() | |
} | |
override fun onResume() { | |
super.onResume() | |
Toast.makeText(this, "SecondActivity: onResume", Toast.LENGTH_SHORT).show() | |
} | |
override fun onPause() { | |
super.onPause() | |
Toast.makeText(this, "SecondActivity: onPause", Toast.LENGTH_SHORT).show() | |
} | |
override fun onStop() { | |
super.onStop() | |
Toast.makeText(this, "SecondActivity: onStop", Toast.LENGTH_SHORT).show() | |
} | |
override fun onRestart() { | |
super.onRestart() | |
Toast.makeText(this, "SecondActivity: onRestart", Toast.LENGTH_SHORT).show() | |
} | |
override fun onDestroy() { | |
super.onDestroy() | |
Toast.makeText(this, "SecondActivity: onDestroy", Toast.LENGTH_SHORT).show() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment