Example usage for android.app AlertDialog.Builder isShowing

List of usage examples for android.app AlertDialog.Builder isShowing

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder isShowing.

Prototype

public boolean isShowing() 

Source Link

Usage

From source file:br.com.anteros.android.persistence.backup.ImportDatabaseTask.java

@Override
protected void onPostExecute(final String errMsg) {
    if (dialog.isShowing()) {
        dialog.dismiss();//from ww  w. j ava2 s  .com
    }

    AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
    dialog.setTitle("Aviso");
    if (errMsg.equals("OK")) {
        dialog.setMessage("Importao realizada com sucesso!");
        Toast.makeText(activity, "Importao realizada com sucesso!", Toast.LENGTH_SHORT).show();
    } else {
        dialog.setMessage("Importao falhou - " + errMsg);
        Toast.makeText(activity, "Importao falhou - " + errMsg, Toast.LENGTH_LONG).show();
    }
    dialog.setCancelable(false);
    dialog.setPositiveButton("Ok", new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog dlg = dialog.create();
    dlg.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            activity.setResult(ImportDatabaseTask.TABLES_RECREATED);
            activity.finish();
        }
    });
    dlg.show();
}