Java tutorial
//package com.java2s; //License from project: Apache License import android.app.ProgressDialog; import android.content.Context; public class Main { private static ProgressDialog loadingDialog; private static synchronized void initDialog(Context ctx, String s) { if (loadingDialog == null && ctx != null) { loadingDialog = new ProgressDialog(ctx); loadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); loadingDialog.setMessage(s); loadingDialog.setCanceledOnTouchOutside(false); } else if (loadingDialog != null && ctx != null && loadingDialog.isShowing()) { loadingDialog.dismiss(); } } public static void dismiss() { if (loadingDialog != null) { loadingDialog.dismiss(); loadingDialog = null; } } }