0

I have a question: Can I show alert Dialog over another application?

I want to notify the user when he received a message. Shows standard notification is not enough. But when I create an AlertDialog, it can't be displayed over other applications.

  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();
            }
        });
    }
Kevin
  • 545
  • 6
  • 14
kpokrywja
  • 199
  • 1
  • 11

1 Answers1

3

You need to have ACTION_MANAGE_OVERLAY_PERMISSION permission to display Alert dialog when your app is not open or if you want to show dialog on other app too.

Check this Link, I mentioned all with details here: pop up wiindow with notification even apllication is not running

How to make AlertDialog view in Input method Service?

Bhoomika Patel
  • 1,895
  • 1
  • 13
  • 30