so I'm looking to create an application to control an arduino car , and i have a alert dialog that pops-up when i click a button , until here , everything works with no problems . But here i have a special thing , when I open the alert dialog by pressing it's button and let's say i press the power button to close my phone , my app crashes , and i tried a lot of things like PowerManager and stuff like that , but it didnt work
So here is the code for the Alert dialog :
void dialogCreater() {
            final AlertDialog.Builder mbuilder = new AlertDialog.Builder(CarActivity.this);
            View mView = getLayoutInflater().inflate(R.layout.settings, null);
            final EditText editForward = mView.findViewById(R.id.editForward);
            final EditText editBackwards = mView.findViewById(R.id.editBackwards);
            final EditText editLeft = mView.findViewById(R.id.editLeft);
            final EditText editRight= mView.findViewById(R.id.editRight);
            final EditText editForwardLeft = mView.findViewById(R.id.editForwardLeft);
            final EditText editForwardRight = mView.findViewById(R.id.editForwardRight);
            final EditText editBackwardsLeft = mView.findViewById(R.id.editBackwardsLeft);
            final EditText editBackwardsRight = mView.findViewById(R.id.editBackwardsRight);
            final EditText editStop = mView.findViewById(R.id.editStop);
            Button mAccept = mView.findViewById(R.id.btnAccept);
            Button mCancel = mView.findViewById(R.id.btnCancel);
            Button mDefaultSettings = mView.findViewById(R.id.btnDefault);
            mbuilder.setView(mView);
            dialog  = mbuilder.create();
            dialog.setCancelable(true);
           // a few buttons for the dialog 
           dialog.show();
Ok so this is the code , and my application crashes at the line from above (dialog.show()) when the dialog is opened and i close the phone This is the error I am getting :
 E/WindowManager: android.view.WindowLeaked: Activity com.example.edi.bluetoothgoogleplay.CarActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{5954400 V.E..... R....... 0,0-832,670} that was originally added here
                         at android.view.ViewRootImpl.<init>(ViewRootImpl.java:363)
                         at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:261)
                         at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
                         at android.app.Dialog.show(Dialog.java:298)
                         at com.example.edi.bluetoothgoogleplay.CarActivity.dialogCreater(CarActivity.java:624)
                         at com.example.edi.bluetoothgoogleplay.CarActivity$12.onClick(CarActivity.java:383)
                         at android.view.View.performClick(View.java:4756)
                         at android.view.View$PerformClick.run(View.java:19761)
                         at android.os.Handler.handleCallback(Handler.java:739)
                         at android.os.Handler.dispatchMessage(Handler.java:95)
                         at android.os.Looper.loop(Looper.java:135)
                         at android.app.ActivityThread.main(ActivityThread.java:5264)
                         at java.lang.reflect.Method.invoke(Native Method)
                         at java.lang.reflect.Method.invoke(Method.java:372)
                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:900)
                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
So if anyone could help me , anything would be apreciated !