android-alertdialog - 在没有窗口类型的服务中显示 AlertDialog
问题描述
我会尝试解释我感兴趣的内容,如果你能帮助我,我会很高兴。您是否知道在不设置类型 TYPE_SYSTEM_ALERT / TYPE_APPLICATION_OVERLAY 的情况下在活动之外(服务中)显示 AlertDialog 的方法?例如以某种方式全局预设它,也许使用 ContextWrapper (我不知道它是否可以完成),然后以标准方式创建 AlertDialog?这似乎是一个奇怪的问题,但我需要它,因为我无法为某些外部警报对话框设置类型,最后我的目标是让这段代码在服务中工作
AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setTitle("Example")
.setMessage("Example")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
解决方案
推荐阅读
- java - 线程“主”java.lang.NoClassDefFoundError 中的异常:org/openqa/selenium/Capabilities
- .net - 检查一个字符串是否至少包含一个存储在子字符串数组中的字符串
- python - 如何使用 python selenium 上传带有角度组件的图像
- css - 如何正确地使“li”元素树彼此靠近
- java - 如何在 Ubuntu 18.04.2 LTS 上使用 OpenJDK 8 运行 Java FX?
- azure - 多个域的 Azure AD 身份验证
- angular2-routing - Angular 7 将应用程序页面重定向到 index.html
- python - Pygame - 运动漂移
- fortran - 哪个 dgemm 调用最快?
- javascript - 从 react-native 中的数组中的对象获取密钥