Can you please explain which activity life cycle method is called when a dialog comes on the application? I'm confused whether its is calling onResume() or onPause() method.
Thanks
Can you please explain which activity life cycle method is called when a dialog comes on the application? I'm confused whether its is calling onResume() or onPause() method.
Thanks
OnPause() is not called in all types of dialogs.
For Example, when an AlertDialog or DialogFragment is used, it will never call OnPause(), since they are a part of the activity.
However, if a dialog appears from System for a permission or some other app shows a Dialog over the activity it will only call OnPause() since a new activity isn't started and only the foreground focus is shifted from the activity to the Dialog Box.
For Example, when we enable Whatsapp to send a message popup, if the popup comes while your activity is running, it will call OnPause() only.
You should try this on your own for better understanding.
onPause is not called because you are still in current activity, so when you are showing dialog on current activity no activity life cycle method will called.
Activity inside if open any dialog, then that dialog not affect to activity life cycle. so i already try this one. so onPause() not called. if any doubt please implement your self you can get more clarity.
I have checked the lifecycle of Activity is changed or not using a AlertDialog and I can see no changes in the lifecycle of activity. When a dialog appears no onPause is called and when a dialog is cancelled no onResume is called.
No lifecycle changes happens if the dialog is called
D/lc1: onCreate
D/lc1: onStart
D/lc1: onResume
I/System.out: lc1 AlertDialog is created
I/System.out: lc1 clicked yes
I/System.out: lc1 AlertDialog is created
I/System.out: lc1 clicked no
I/System.out: lc1 AlertDialog is created
I/System.out: lc1 clicked cancel
D/lc1: onPause
D/lc1: onStop