更新时间:2023-01-24 13:25:02
在短:是的不可以可以
只有活动的可以创建/显示对话框。事实上,这已被要求超过一次:
Only Activity's can create/show dialogs. In fact, this has been asked more then once:
另外,为什么要启动一个对话框?
Also, why would you want to launch a Dialog?
事实上,你可以创建/显示 吐司
从的BroadcastReceiver
。这吐司
也将蜜蜂当用户应用程序中的不显示。
In fact, you can create/show a Toast
from an BroadcastReceiver
. This Toast
will also bee shown when the user is not "in your application".
此外,您还可以发送从的BroadcastReceiver
的通知(在屏幕顶部显示在通知酒吧)。如何做到这一点一个教程(它不会从不同你如何做一个活动,但您使用通过上下文
-object从的onReceive
- 方法)。
Also, you can send a Notification (shown in the Notification-Bar at the top of your screen) from a BroadcastReceiver
. A tutorial on how to do this (it does not differ from how you do it in an Activity, except that you use the passed Context
-Object from the onReceive
-method).
当用户应用程序中的不是,是(在我看来)最适合解决这个问题的通知也将被显示。
The Notification will also be shown when the user is not "in your application" and is the (in my eyes) best suited solution to this problem.