BroadcastReceiver onReceive打开对话框

时间:2013-07-28 07:34:57

标签: android dialog broadcastreceiver

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

我怎么能这样做?

谢谢!

1 个答案:

答案 0 :(得分:5)

如果您想从BroadcastReceiver的onReceive内部显示一个对话框,您可以在广播接收器内开始一个带有警告对话框的透明活动,并且永远不要调用setContentView()。活动将具有透明视图,仅显示警报对话框。 来源: show an alert dialog in broadcast receiver after a system reboot

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

  1. AlertDialog from within BroadcastReceiver?? Can it be done?

  2. How to raise an alert dialog from BroadcastReceiver class?

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

  4. How to setup Alertbox from BroadcastReceiver

  5. 希望这会有所帮助。