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

北城以北 提交于 2019-12-06 06:30:37

问题


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?

Thanks!


回答1:


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. http://developer.android.com/reference/android/view/View.html



来源:https://stackoverflow.com/questions/7313852/android-how-can-i-launch-a-popup-dialog-from-an-notification-or-long-pressed-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!