我在建设有广播接收器 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打开对话框
发布评论