Is there any way to show a modeless dialog--a dialog that allows the user to interact with whatever was on the screen before the dialog but also allows the user to interact with the dialog if pressed?
I know of Toasts, but they don't allow interaction with the popup.
I know of Dialogs, but they're modal and don't allow interaction with the background.
I know of Notifications, but I want something that is visibile on screen.
I basically want to be able to be playing a game or something and a popup appears that I have a new email or something. I can click it to view my email, but I can wait for it to go away if I just want to continue playing my game. Is this possible in Android?
Yes, create an Activity with style
Theme.Dialog
. This is a normal activity which looks like a dialog, while being modeless and accepting events.An example:
Edited:
Indeed
Theme.Dialog
blurs the underlying activity and makes it unaccessible. I had a similar requirement here I had to show upload progress dialog with text and cancel button. The main catch is in settingWindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
and resettingWindowManager.LayoutParams.FLAG_DIM_BEHIND
.Created a Dialog with custom content:
And this is the layout for this Dialog:
My implementation which was a little more hackish but also allows button presses to be caught by background window
just add FLAG_NOT_TOUCH_MODAL flag to your dialog