问题
I've got an app that responds to an Alert - and I really need to show an alert with a password entry before going on to the next screen; the trouble is I don't seem to be able to show a dialog from a broadcast receiver -- so how can I show a dialog password entry upon receiving an alert?
回答1:
Create an activity, using Theme.Dialog
, and call startActivity()
to open it. While you cannot use a "real" Dialog
, you can create a UI that looks like a Dialog
.
Bear in mind that popping up an activity based on a broadcast may greatly irritate some users, who might not appreciate your dialog appearing in the middle of their game or text message conversation or whatever. You may wish to consider actually raising a Notification
, then displaying the dialog when they open up that Notification
.
回答2:
Go through the link below this is the complete example how to make a custom dialog and call it automatically and gets pop up when the internet gets down hope it works for you
Click Here
来源:https://stackoverflow.com/questions/3693547/android-broadcast-receiver-showing-a-dialog