Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle the 'back button' on android when I have a progress dialog pops up

Tags:

android

When my android activity pops up a progress dialog, what is the right way to handle when user clicks the back button?

Thank you.

like image 479
michael Avatar asked Oct 08 '10 19:10

michael


People also ask

Does Back button Finish activity android?

If you hit the back button, then your Activity is finished and is destroyed, always resulting in a call to onDestroy().

What is progress dialog in android?

Android ProgressDialog is a dialog box/dialog window which shows the progress of a task. Android Progress Dialog is almost same as ProgressBar with the exception that this is displayed as a dialog box. In order to create a ProgressDialog to display a ProgressBar we need to instantiate it like this.

How do you back press on android?

In order to check when the 'BACK' button is pressed, use onBackPressed() method from the Android library. Next, perform a check to see if the 'BACK' button is pressed again within 2 seconds and will close the app if it is so. Otherwise, don't exit.


1 Answers

Make a new dialog object that extends ProgressDialog, then override the public void onBackPressed() method within it.

like image 109
AndrewKS Avatar answered Nov 14 '22 22:11

AndrewKS