I wanted to know if it is possible in Android to retain the popup displayed on top of the activity even if the home button is pressed.
Example: I have an activity which contains a button. When the button is clicked a popup is displayed and now i press the home button. What I want is activity should close but not the popup 🙂
I wanted to know if it is possible in Android to retain the popup
Share
No, Dialogs/Pop-ups are attached to activity’s window and are relying on activity’s life-cycle. So you cant retain/show a dialog once the parent window is away (or in stopped state).
To get this done, you may initiate a new
Activitywith the themeandroid:theme="@android:style/Theme.Dialog"defined in AndroidManifest.xml. This will emulate your activity as a dialog/pop-up window and will contain its own life-cycle.