Example usage for android.content DialogInterface.OnKeyListener DialogInterface.OnKeyListener

List of usage examples for android.content DialogInterface.OnKeyListener DialogInterface.OnKeyListener

Introduction

In this page you can find the example usage for android.content DialogInterface.OnKeyListener DialogInterface.OnKeyListener.

Prototype

DialogInterface.OnKeyListener

Source Link

Usage

From source file:og.android.tether.MainActivity.java

public Dialog openLaunchedDialog(final boolean noroot) {
    final long value = noroot ? 1 : 0;
    EasyTracker.getTracker().trackEvent("ui_action", "create_dialog", "meshclient", value);
    Dialog dialog = new AlertDialog.Builder(this)
            .setMessage(noroot ? R.string.dialog_noroot_text : R.string.dialog_launched_text)
            .setTitle(getString(R.string.dialog_launched_title)).setIcon(R.drawable.og_app_icon)
            .setCancelable(false).setOnKeyListener(new DialogInterface.OnKeyListener() {
                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                    if (keyCode == KeyEvent.KEYCODE_BACK)
                        MainActivity.this.finish();
                    if (keyCode < KeyEvent.KEYCODE_DPAD_UP || keyCode > KeyEvent.KEYCODE_DPAD_CENTER)
                        return true;
                    else
                        return false;
                }/*from w w  w.j  a v  a2s  .  co m*/
            }).setPositiveButton(getString(R.string.main_activity_ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    EasyTracker.getTracker().trackEvent("ui_action", "button_press", "meshclient_positive",
                            value);
                    startGooglePlayMeshclient(noroot ? "fail_noroot" : "fail");
                }
            })
            .setNegativeButton(getString(R.string.main_activity_cancel), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    EasyTracker.getTracker().trackEvent("ui_action", "button_press", "meshclient_negative",
                            value);
                }
            }).create();
    dialog.show();
    return dialog;
}

From source file:net.nightwhistler.pageturner.activity.ReadingFragment.java

private ProgressDialog getWaitDialog() {

    if (this.waitDialog == null) {
        this.waitDialog = new ProgressDialog(context);
        this.waitDialog.setOwnerActivity(getActivity());
    }/*  ww w  . j  a  va2 s  . c o  m*/

    this.waitDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            // This just consumes all key events and does nothing.
            return true;

        }
    });

    return this.waitDialog;
}