我正在使用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
发布评论