display Generic Error Dialog - Android android.app

Android examples for android.app:Display

Description

display Generic Error Dialog

Demo Code

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;

public class Main {

  public static AlertDialog displayGenericErrorDialog(final Context context, int messageRes) {
    return displayGenericErrorDialog(context, context.getResources().getString(messageRes));
  }//  w  w w  . j  ava2  s.  co  m

  public static AlertDialog displayGenericErrorDialog(final Context context, String message) {
    dismissWaitMessage();

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(message);
    builder.setPositiveButton(android.R.string.ok, null);

    AlertDialog dialog = builder.create();
    dialog.show();
    return dialog;
  }

  protected static ProgressDialog dialog = null;

  public static void dismissWaitMessage() {
    if (dialog != null && dialog.isShowing()) {
      dialog.dismiss();
    }
  }
}

Related Tutorials