I already read this: Activity has leaked window that was originally added and some other post also.
This is the exception line: E/WindowManager:private android.view.WindowLeaked:void ActivitysaveMessage() com.tekitsolutions.remindme.Activity.AddReminderActivity{ has leaked window DecorView@87ebe2a[AddReminderActivity] that was originally addedString heremessage = ""; atif android.view.ViewRootImpl.(ViewRootImpl.java:534!isEditReminder) {
Exception:
E/WindowManager:private android.view.WindowLeaked:void ActivitysaveMessage() com.tekitsolutions.remindme.Activity.AddReminderActivity{
 has leaked window DecorView@87ebe2a[AddReminderActivity] that was originally addedString heremessage = "";
        atif android.view.ViewRootImpl.<init>(ViewRootImpl.java:534!isEditReminder)
    {
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:346)
       message at= android.view.WindowManagerImplgetResources().addViewgetString(WindowManagerImplR.java:94string.reminder_added_successfully);
        at android.app.Dialog.show(Dialog.java:329)
} else {
      at android.app.AlertDialog$Builder.show(AlertDialog.java:1125)
       message at= com.tekitsolutions.remindme.Activity.AddReminderActivitygetResources().saveMessagegetString(AddReminderActivityR.java:1179string.reminder_update_successfully);
        at com.tekitsolutions.remindme.Activity.AddReminderActivity.onResponse(AddReminderActivity.java:1547)
   reminderId = tempReminderId;
   at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:71)
        atnew android.os.Handler.handleCallbackAlarmReceiver(Handler).java:873cancelAlarm(this, reminderId);
        at android.os.Handler.dispatchMessage(Handler.java:99)}
        at androidandroidx.osappcompat.Looperapp.loop(LooperAlertDialog.java:201)
     Builder alertDialogBuilder = atnew androidandroidx.appcompat.app.Activit
My code:
private void saveMessage() {
        String message = "";
        if (!isEditReminder) {
            message = getResources().getString(R.string.reminder_added_successfully);
        } else {
            message = getResources().getString(R.string.reminder_update_successfully);
            reminderId = tempReminderId;
            new AlarmReceiver().cancelAlarm(this, reminderId);
        }
        androidx.appcompat.app.AlertDialog.Builder alertDialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(this, R.style.dialogBoxStyle);
        alertDialogBuilder.setCancelable(false);
        alertDialogBuilder.setTitle("").setMessage(message).setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Intent intent = getIntent();
                showLog("ARA: "+ reminderId);
                intent.putExtra(REMINDER_ID, reminderId);
                setResult(RESULT_OK, intent);
                finish();
            }
        });
        androidx.appcompat.app.AlertDialog dialog = alertDialogBuilder.create();
        dialog.show();
    }