I have created a Popup window which contains month view to pick up date. When I changes orientation, due to Android loads an activity all over again my popup Window gets dis
Whenever there is an orientation change, Android destroys your activity ( calls onDestroy()
) and then restarts it (calls onCreate()
).
As soon as your popup is up, set a flag popup_open=1
. Your popup will naturally have a dismiss button. Set the flag=0 in the click handler of this button. You can then re-open the popup when the app restarts in the method onRestoreInstanceState()
or in the onCreate()
. Here you would make a check for the flag. If the flag is set to 1, bring up the popup. So even if the orientation changed while the popup was up, onRestoreInstanceState()
will know what to do based onthe state of the flag.
For more reference check: How to handle runtime changes.