Example usage for android.app AlertDialog.Builder setCancelable

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

Introduction

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

Prototype

public void setCancelable(boolean flag) 

Source Link

Document

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.

Usage

From source file:com.gnuroot.rsinstaller.RSLauncherMain.java

/**
 * Displays an alert dialog if GNURoot Debian isn't updated to at least the version that included the
 * new ecosystem changes. Sends the user to the market page for it if not.
 *///w ww .  j a va 2 s . com
private void showUpdateError() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setCancelable(false);
    builder.setMessage(R.string.update_error_message);
    builder.setPositiveButton(R.string.button_affirmative, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://details?id=com.gnuroot.debian"));
            startActivity(intent);
            finish();
        }
    });
    builder.create().show();
}

From source file:com.dipesan.miniatm.miniatm.services.RiskManagementTask.java

@Override
public void execute(ITaskMonitor monitor) {
    this.monitor = monitor;

    activity.runOnUiThread(new Runnable() {
        @Override//from www. jav  a2  s.  c  om
        public void run() {
            AlertDialog.Builder builder = new AlertDialog.Builder(activity);

            builder.setTitle("Risk management");
            builder.setCancelable(false);
            builder.setMessage("Is card stolen ?");

            builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    end(new byte[] { 0, 0b10000, 0, 0, 0 });
                }
            });

            builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    end(new byte[] { 0, 0, 0, 0, 0 });
                }
            });

            builder.create().show();
        }
    });
}

From source file:it.sasabz.android.sasabus.InfoActivity.java

/**
 * Called when the activity is about to start interacting with the user.
 *///from   ww w . j a va  2 s  .  c om
@Override
protected void onResume() {
    super.onResume();
    if (haveNetworkConnection())
        fillData();
    else {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setCancelable(true);
        builder.setMessage(R.string.no_network_connection);
        builder.setTitle(R.string.error_title);
        builder.setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
                dialog.dismiss();
            }
        });
        builder.create().show();
    }
}

From source file:at.tomtasche.reader.ui.widget.RecentDocumentDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new Builder(getActivity());
    builder.setTitle(R.string.dialog_recent_title);
    builder.setCancelable(true);

    TextView emptyView = new TextView(getActivity());
    emptyView.setText(R.string.dialog_loading_title);

    listView = new ListView(getActivity());
    listView.setEmptyView(emptyView);/*from  w  w w.jav  a2s .  co m*/
    listView.setOnItemClickListener(this);
    listView.setOnItemLongClickListener(this);

    adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, new String[0]);
    listView.setAdapter(adapter);

    builder.setView(listView);

    setCancelable(true);

    items = new HashMap<String, String>();

    loadRecentDocuments();

    listView.setEmptyView(emptyView);

    return builder.create();
}

From source file:com.heliopause.nope.fragments.AboutFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.about_list);

    WebView mWebView = new WebView(getPreferenceScreen().getContext());
    mWebView.loadUrl("file:///android_asset/licenses/licenses_html");

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setCancelable(true).setView(mWebView).setTitle(R.string.license_title);
    mTextDlg = builder.create();/*from   w ww  . jav a2 s  . c  o m*/
    mTextDlg.setOnDismissListener(new DialogInterface.OnDismissListener() {

        public void onDismiss(DialogInterface dialog) {
            dialog.dismiss();
        }
    });

    // Setup pref items
    Preference mRateAppPref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_RATE_APP);
    if (mRateAppPref != null) {
        mRateAppPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {

                try {
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("market://details?id=" + getActivity().getPackageName())));
                } catch (android.content.ActivityNotFoundException anfe) {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                            "http://play.google.com/store/apps/details?id=" + getActivity().getPackageName())));
                }
                return true;
            }

        });
    }
    Preference mContactDevPref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_CONTACT_DEV);
    if (mContactDevPref != null) {
        mContactDevPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                Uri data = Uri.parse("mailto:" + getActivity().getString(R.string.developer_email));
                intent.setData(data);
                startActivity(intent);
                return true;
            }
        });
    }
    Preference mReportBugPref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_REPORT_BUG);
    if (mReportBugPref != null) {
        mReportBugPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {

                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(getActivity().getString(R.string.report_bug_url)));
                startActivity(intent);
                return true;
            }
        });
    }
    Preference mOpenSourcePref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_OPEN_SOURCE);
    if (mOpenSourcePref != null) {
        mOpenSourcePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                mTextDlg.show();
                return true;
            }
        });
    }
    mVersionPref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_VERSION);

}

From source file:com.springsource.greenhouse.twitter.PostTweetActivity.java

private void showResult(String result) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(result);//from  w  ww .j  a v  a  2 s . c  om
    builder.setCancelable(false);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.example.clienttest.AbstractGreenhouseActivity.java

protected void displayAuthorizationError() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("You are not authorized to connect to Greenhouse. Please reauthorize the app.");
    builder.setCancelable(false);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            signOut();/*from   w  w  w.  ja  va 2 s  .  co m*/
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java

/**
 * Creates a dialog for given message.//www . ja va2 s .  c  om
 *
 * @param activity
 *            Parent activity.
 * @param message
 *            Message contents
 * @param dismissListener
 *            Listener that will be called when dialog is closed or
 *            cancelled.
 * @return Created dialog.
 */
public static Dialog createMessageDialog(Activity activity, Message message,
        OnDismissListener dismissListener) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    final String title = message.description == null ? null
            : message.description.get(MessageDescription.KEY_TITLE);
    if (!Utilities.isNullOrEmpty(title)) {
        builder.setTitle(title);
    }

    final View dialogContentsView = createMessageDialogContentsView(activity, message.description);
    builder.setView(dialogContentsView);

    initializeMessageDialogButtons(activity, builder, message);
    builder.setCancelable(true);

    final AlertDialog dialog = builder.create();

    if (Utilities.isNullOrEmpty(title)) {
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }

    dialog.setOnDismissListener(dismissListener);
    return dialog;
}

From source file:com.springsource.greenhouse.events.sessions.EventSessionRatingActivity.java

private void showResult(String result) {
    //      Toast.makeText(this, result, Toast.LENGTH_LONG).show();
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(result);//from   w  w  w .  j av a  2s  . c o m
    builder.setCancelable(false);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java

/**
 * Show a dialog asking if unsaved edits should be ignored. Finish if so.
 *///from   w  w  w .  j  a v  a 2 s .  com
public static void showConfirmUnsavedEditsDialog(final Activity a, final Runnable r) {
    AlertDialog.Builder dialog = new Builder(a);

    dialog.setTitle(R.string.details_have_changed);
    dialog.setMessage(R.string.you_have_unsaved_changes);

    dialog.setPositiveButton(R.string.exit, new AlertDialog.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (r != null) {
                r.run();
            } else {
                a.finish();
            }
        }
    });

    dialog.setNegativeButton(R.string.continue_editing, new AlertDialog.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    dialog.setCancelable(false);
    dialog.create().show();
}