kevdliu kevdliu - 1 year ago 86
Android Question

ANDROID: How can I launch a popup dialog from an notification or long-pressed search button on top of all windows?

I have searched and everything is about launching an activity not a dialog.

What I want to do is to display a notification in the status bar, and when the user presses it a dialog pops up on top of whatever the user was viewing before s/he clicked the notification. I dont want the dialog to show on top of the main activity or the recent apps list.

Also, how can i launch the dialog from long pressing the search button?


Answer Source

I'm copying from here: Here is answer

to Start activity as dialog i defined

<activity android:theme="@android:style/Theme.Dialog">

now when i startActivity() it display like dialog and parent activity display on back, i wan a button to whom i click dialog should dismiss and parent activity should display without refreshing the page.

And then somebody added the comment:

Using the android:theme="@android:style/Theme.Dialog" is the way to go but don't forget to use excludeFromRecents=true or else your dialog will appear in the Recently Used Apps (hold the Home key).

And for the long press, override onKeyLongPress(int keyCode, KeyEvent event) and you can make the long press do what you want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download