BroadcastReceiver onReceive打开对话框(BroadcastReceiver onReceive open dialog)

编程入门 行业动态 更新时间:2024-10-23 14:27:54
BroadcastReceiver onReceive打开对话框(BroadcastReceiver onReceive open dialog)

我正在使用BroadcastReceiver构建一个Android应用程序,我希望在onReceive启动时显示一个对话框。 我想在手机上显示对话框(无论他在哪里,都会向用户显示一个对话框,比如收到消息时的whatsapp对话框)。

我怎么能这样做?

谢谢!

I'm building an android application with BroadcastReceiver and I want to show a dialog when onReceive starts. I want to show the dialog on the phone (show the user a dialog no matter where he is, like the whatsapp dialog when you get a message).

How I can do that?

Thanks!

最满意答案

如果你想在广播接收器的onReceive中显示一个对话框,你可以在广播接收器内启动一个带有警告对话框的透明活动,并且从不调用setContentView() 。 活动将具有透明视图,仅显示警报对话框。 来源: 系统重启后在广播接收器中显示警告对话框

有很多类似的帖子谈论这个话题。 有关代码示例和相同的其他评论,请参阅以下问题:

BroadcastReceiver中的AlertDialog ?? 可以吗?

如何从BroadcastReceiver类引发警报对话框?

如何从Android广播接收器显示对话框?

如何从BroadcastReceiver设置Alertbox

希望这会有所帮助。

If you want to show a dialog from inside your onReceive of the BroadcastReceiver, inside your broadcast receiver you may start a transparent activity with an alert dialog and NEVER called setContentView(). The activity will have an transparent view and only the alert dialog will show. Source: show an alert dialog in broadcast receiver after a system reboot

There are many similar posts which talk about this topic. See below questions for code samples and other reviews on the same:

AlertDialog from within BroadcastReceiver?? Can it be done?

How to raise an alert dialog from BroadcastReceiver class?

How can I display a dialog from an Android broadcast receiver?

How to setup Alertbox from BroadcastReceiver

Hope this will help.

更多推荐

对话框,BroadcastReceiver,电脑培训,计算机培训,IT培训"/> <meta name="descrip

本文发布于:2023-07-23 18:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1235697.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   onReceive   BroadcastReceiver   open   dialog

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!