ANDROID: How can I launch a popup dialog from an n

2019-04-11 17:49发布

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条回答
老娘就宠你
2楼-- · 2019-04-11 18:44

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

查看更多
登录 后发表回答