When my android activity pops up a progress dialog, what is the right way to handle when user clicks the back button?
Thank you.
If you hit the back button, then your Activity is finished and is destroyed, always resulting in a call to onDestroy().
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.
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.
Make a new dialog object that extends ProgressDialog, then override the public void onBackPressed() method within it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With