I am an Android app developer.
I thought I know the life cycle of the activity.
But... I am confused now.
As per the official docs: https://developer.android.com/guide/components/activities/activity-lifecycle.html#onpause
'onPause' is called when partially invisible.
A new, semi-transparent activity (such as a dialog) opens. As long as the activity is still partially visible but not in focus, it remains paused.
So I have thought that if a dialog is opened, then the activity is paused.
I made some sample code to prove this.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
btn.setOnClickListener {
// 1. AlertDialog
// AlertDialog.Builder(this)
// .setTitle("TEST")
// .show()
// 2. DialogFragment
// val dialog = TestFragment()
// supportFragmentManager.beginTransaction().add(dialog, "").commit()
}
}
override fun onPause() {
super.onPause()
Log.d("TEST", "[LifeCycle] onPause")
}
When I clicked the "btn", Dialog/DialogFragment is opened. But 'onPause' log was not printed out.
I am confused...
Does the official document incorrect?