Android广播接收器显示一个对话框?

时间:2023-04-24
本文介绍了Android广播接收器显示一个对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个响应警报的应用程序 - 在进入下一个屏幕之前,我确实需要显示带有密码输入的警报;问题是我似乎无法显示来自广播接收器的对话框 - 那么如何在收到警报时显示对话框密码输入?

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?

推荐答案

创建一个activity,使用Theme.Dialog,调用startActivity()打开它.虽然您不能使用真正的"Dialog,但您可以创建一个看起来像 Dialog 的 UI.

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.

请记住,根据广播弹出活动可能会极大地激怒某些用户,他们可能不喜欢您的对话出现在他们的游戏或短信对话或其他任何事情的中间.您可能希望考虑实际提出一个 Notification,然后在他们打开该 Notification 时显示对话框.

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.

这篇关于Android广播接收器显示一个对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:在android中显示对话框时我们可以与后台活动交互吗 下一篇:如何将自定义列表视图设置为对话框

相关文章