Right place to initialise Progress Dialogs

It is always easy to create a function in the Util class created which is being used in all other activities. But when progress dialog is created there is a little possibility that we might get an exception.

BadTokenException

This exception is mainly because the progress dialog is not initialise. So, to overcome this problem I will suggest a right place to initialise progress dialog. It should be initialised right above the code line where it is shown.

void requestToServer(){
       //Initialise progress dialog here
       // show progress dialog here
      onResponse(){
             //dismiss progress dialog
      }
}

Comments

Popular posts from this blog

Styling Bottom Navigation

Lottie Animation in Android

Set Up the AWS Mobile SDK for Android