广播接收器的onReceive打开对话框

编程入门 行业动态 更新时间:2024-10-08 06:26:02
本文介绍了广播接收器的onReceive打开对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在建设有广播接收器 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).

我怎么能这样做?

谢谢!

推荐答案

如果你想显示从内您的广播接收器的的onReceive 一个对话框,您广播接收机里面你可能会启动一个透明的活动与警报对话框,从来不叫的setContentView()。活动将有一个透明的观点,只有警告对话框将显示。的来源:的show一个警告对话框中广播接收系统重启后

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

有哪些谈论这个话题很多类似的帖子。请参见下面的同样为code样品问题和其他评论:

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

  • AlertDialog从内部广播接收器?这是可以做到?

    how从BroadcastReciever类提出一个警告对话框?

    How我可以从Android广播接收器显示一个对话框?

    如何设置Alertbox从广播接收器

    希望这会有所帮助。

  • 更多推荐

    广播接收器的onReceive打开对话框

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

    发布评论

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

    >www.elefans.com

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