I have Progress Dialog Class which is singleton
public class ProgressDialogManager {
private static ProgressDialogManager manager = null;
private Context context;
private ProgressDialog pDialog = null;
private ProgressDialogManager(Context context) {
this.context = context;
}
public static ProgressDialogManager getInstance(Context context) {
if (manager == null)
manager = new ProgressDialogManager(context);
return manager;
}
public void showDialog(String msg) {
if (pDialog == null)
pDialog = new ProgressDialog(this.context);
pDialog.setMessage(msg);
pDialog.show();
}
public void closeDialog() {
if (pDialog != null) {
pDialog.dismiss();
}
}
}
when getInstance(this) method multiple activity I get and error
android.view.WindowManager$BadTokenException: Unable to add window — token android.os.BinderProxy@447a6748 is not valid; is your activity running?
my question is Is it Good practice Progress Dialog As Singleton Class and what is the reason of Error how to solved it