Skip to content

Instantly share code, notes, and snippets.

@amsterdatech
Created January 26, 2021 22:53
Show Gist options
  • Save amsterdatech/1da93b6a7fd4ebb17817808d6f20f23d to your computer and use it in GitHub Desktop.
Save amsterdatech/1da93b6a7fd4ebb17817808d6f20f23d to your computer and use it in GitHub Desktop.
abstract class BaseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
log("onCreate()")
super.onCreate(savedInstanceState)
}
override fun onStart() {
log("onStart()")
super.onStart()
}
override fun onResume() {
log("onResume()")
super.onResume()
}
override fun onPause() {
log("onPause()")
super.onPause()
}
override fun onStop() {
log("onStop()")
super.onStop()
}
override fun onDestroy() {
log("onDestroy()")
super.onDestroy()
}
private fun log(lifecycle: String) {
Log.d("Lifecycle", "${this.javaClass.simpleName} $lifecycle in ${this.javaClass.`package`?.name}") // Then send to analytics
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment