Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the back button when the alert box is on the screen

Tags:

android

dialog

I used onKeyDown function in the activity.....but when back button button is clicked it first cancels the dialog box and goes to our activity...I want both either both activity and dialog box closed when clicking the back button or disable the back button when the dialog box is shown...

can any one suggest any solutions for this....

Thanks in advance,


Update

Hello Thanks for your answer. The progressDialog with .setCancelable(false); is working fine.

But here I want different thing. When the progress dialog is running then i will press the BACK key and i want to show an alert dialog so that the user can notify that the progress is running.

Is there any solution about it?

Please help me.

Thanks in advance.

like image 955
gsmaker Avatar asked Aug 30 '10 09:08

gsmaker


People also ask

How to disable back press in Flutter?

To disable back button in Flutter, you can use the WillPopScope widget. The WillPopScope widget helps you get a callback whenever the back button is pressed. Inside the callback, if you return true the screen will be popped and if you return false, you have simply disabled the back button.

How do you dismiss dialog automatically in Flutter?

The below code will close AlertBox/DialogBox in Flutter. Navigator. of(context). pop();

How do you use showDialog Flutter?

showDialog<T> function Null safety. Displays a Material dialog above the current contents of the app, with Material entrance and exit animations, modal barrier color, and modal barrier behavior (dialog is dismissible with a tap on the barrier). This function takes a builder which typically builds a Dialog widget.


1 Answers

Did you try setting its setCancelable() property to false

Something like this

progressDialog.setCancelable(false); 
like image 96
DeRagan Avatar answered Sep 20 '22 02:09

DeRagan