【问题标题】:Andorid: show Dialog over other appsAndroid:在其他应用程序上显示对话框
【发布时间】:2019-10-21 05:01:49
【问题描述】:

我有一个问题:我可以在另一个应用程序上显示警报对话框吗?

我想在用户收到消息时通知他。显示标准通知是不够的。但是当我创建一个 AlertDialog 时,它无法显示在其他应用程序上。

  private void showAlertDialog(View view, Order order, Order oldOrder) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        LayoutInflater inflater = LayoutInflater.from(context);
        View content = inflater.inflate(R.layout.dialog_extra_info, null);
        builder.setView(content);
        final EditText etKmCounter = content.findViewById(R.id.et_km_counter);
        final EditText etMotoHourCounter = content.findViewById(R.id.et_counter_moto_hour);
        final AlertDialog ad = builder.show();

        Button btnSave = content.findViewById(R.id.save);
        btnSave.setOnClickListener(v -> {
            if (StringUtils.isEmpty(etKmCounter.getText().toString()) || StringUtils.isEmpty(etMotoHourCounter.getText().toString())) {
                openFillDataAlertDialog();
            } else {
                ad.dismiss();
            }
        });
    }

【问题讨论】:

标签: android


【解决方案1】:

您需要拥有ACTION_MANAGE_OVERLAY_PERMISSION 权限才能在您的应用未打开或您也想在其他应用上显示对话框时显示警报对话框。

检查这个链接,我在这里提到了所有细节: pop up wiindow with notification even apllication is not running

How to make AlertDialog view in Input method Service?

【讨论】:

  • @kpokrywja 试试这个解决方案,如果您对此有任何疑问,请告诉我。
猜你喜欢
  • 2016-10-31
  • 1970-01-01
  • 2018-08-01
  • 2014-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多