Android Progress Dialog Create showProgressDialog(String msg)

Here you can find the source of showProgressDialog(String msg)

Description

This method will show the progress dialog with given message in the given activity's context.
The progress dialog will be non cancellable by default.

Parameter

Parameter Description
msg = String msg to be displayed in progress dialog. screen each time this method is called.

Declaration

public static void showProgressDialog(String msg) 

Method Source Code

//package com.java2s;

import android.app.Activity;

import android.app.ProgressDialog;

public class Main {
    public static Activity mSmartAndroidActivity;
    private static ProgressDialog progress = null;
    private static String progressMsg = "";

    /**//from   w  w  w .  j av a2 s .  com
     * This method will show the progress dialog with given message in the given
     * activity's context.<br>
     * The progress dialog will be non cancellable by default. User can not
     * dismiss it by pressing back IjoomerButton.
     * 
     * @param msg
     *            = String msg to be displayed in progress dialog. screen each
     *            time this method is called.
     */
    public static void showProgressDialog(String msg) {
        progressMsg = msg;

        mSmartAndroidActivity.runOnUiThread(new Runnable() {
            public void run() {
                progress = ProgressDialog.show(mSmartAndroidActivity, "",
                        progressMsg);
            }
        });
    }

    /**
     * This method will show the progress dialog with given message in the given
     * activity's context.<br>
     * The progress dialog can be set cancellable by passing appropriate flag in
     * parameter. User can dismiss the current progress dialog by pressing back
     * IjoomerButton if the flag is set to <b>true</b>; This method can also be
     * called from non UI threads.
     * 
     * @param msg
     *            = String msg to be displayed in progress dialog.
     * @param isCancellable
     *            = is cancellable or not
     */
    public static void showProgressDialog(String msg,
            final boolean isCancellable) {
        progressMsg = msg;

        mSmartAndroidActivity.runOnUiThread(new Runnable() {
            public void run() {
                progress = ProgressDialog.show(mSmartAndroidActivity, "",
                        progressMsg);
                progress.setCancelable(isCancellable);
            }
        });
    }
}

Related

  1. stallWithProgressDialog(Context context, String title, String msg, boolean indeter, boolean cancelable, int stallTime)
  2. showProgressDialog(Context mContext, CharSequence processMessage)
  3. showProgressDialog(Context c, String title, String msg)
  4. hideProgressDialog()
  5. showProgressDialog(String msg, final boolean isCancellable)
  6. showProgressBar(ProgressDialog progressBar, String message)