Android Broadcast Receiver showing a dialog?

▼魔方 西西 提交于 2019-12-02 02:48:08

问题


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

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