Example usage for android.content DialogInterface cancel

List of usage examples for android.content DialogInterface cancel

Introduction

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

Prototype

void cancel();

Source Link

Document

Cancels the dialog, invoking the OnCancelListener .

Usage

From source file:ela.riskey.parammod.MainActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CODE:
        if (resultCode == RESULT_OK) {
            if (data != null) {
                final Uri uri = data.getData();

                try {
                    final File file = FileUtils.getFile(uri);
                    Global.fbackup = file.toString();
                    rDialog = new AlertDialog.Builder(MainActivity.this);
                    rDialog.setTitle(R.string.app_name);
                    rDialog.setMessage(R.string.wrestore);
                    rDialog.setPositiveButton(R.string.ya, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            new restoreParam().execute();
                        }//from www  .ja  v  a 2 s  . c o m
                    });
                    rDialog.setNegativeButton(R.string.tak, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            dialog.cancel();
                        }
                    });
                    rDialog.create();
                    rDialog.show();
                } catch (Exception e) {
                    Log.e("FileSelectorTestActivity", "File select error", e);
                }
            }
        }
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.duy.pascal.ui.editor.EditorActivity.java

@Override
public void onBackPressed() {
    if (mDrawerLayout.isDrawerOpen(GravityCompat.START) || mDrawerLayout.isDrawerOpen(GravityCompat.END)) {
        mDrawerLayout.closeDrawers();//from   w  ww  .  ja v a  2  s . c om
        return;
    }

    if (getPreferences().getBoolean(getString(R.string.key_back_undo)) && getEditorFragment() != null) {
        getEditorFragment().undo();
        return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.exit).setMessage(R.string.exit_mgs)
            .setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    EditorActivity.super.onBackPressed();
                }
            }).setPositiveButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            }).setNeutralButton(R.string.get_more_app, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    StoreUtil.moreApp(EditorActivity.this);
                }
            });
    showDialog(builder.create());
}

From source file:com.piusvelte.sonet.core.StatusDialog.java

@Override
protected void onResume() {
    super.onResume();
    Intent intent = getIntent();/*w ww  .  j a v a2s . co m*/
    if (intent != null) {
        if (intent.hasExtra(Widgets.INSTANT_UPLOAD)) {
            mFilePath = intent.getStringExtra(Widgets.INSTANT_UPLOAD);
            Log.d(TAG, "upload photo?" + mFilePath);
        } else {
            mData = intent.getData();
            if (mData != null) {
                mData = intent.getData();
                if (intent.hasExtra(LauncherIntent.Extra.Scroll.EXTRA_SOURCE_BOUNDS))
                    mRect = intent.getParcelableExtra(LauncherIntent.Extra.Scroll.EXTRA_SOURCE_BOUNDS);
                else
                    mRect = intent.getSourceBounds();
                Log.d(TAG, "data:" + mData.toString());
                // need to use a thread here to avoid anr
                mLoadingDialog = new ProgressDialog(this);
                mLoadingDialog.setMessage(getString(R.string.status_loading));
                mLoadingDialog.setCancelable(true);
                mLoadingDialog.setOnCancelListener(new OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface arg0) {
                        if (mStatusLoader != null)
                            mStatusLoader.cancel(true);
                        finish();
                    }
                });
                mLoadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
                        new OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.cancel();
                                finish();
                            }
                        });
                mLoadingDialog.show();
                mStatusLoader = new StatusLoader();
                mStatusLoader.execute();
            }
        }
    }
    if (mFilePath != null) {
        mDialog = (new AlertDialog.Builder(this)).setTitle(R.string.uploadprompt)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        startActivityForResult(
                                Sonet.getPackageIntent(getApplicationContext(), SonetCreatePost.class)
                                        .putExtra(Widgets.INSTANT_UPLOAD, mFilePath),
                                RESULT_REFRESH);
                        dialog.dismiss();
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        StatusDialog.this.finish();
                    }
                }).create();
        mDialog.show();
    } else {
        // check if the dialog is still loading
        if (mFinish)
            finish();
        else if ((mLoadingDialog == null) || !mLoadingDialog.isShowing())
            showDialog();
    }
}

From source file:com.citrus.sample.UIActivity.java

private void promptAutoLoadSubscription() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(UIActivity.this);
    String message = null;//www  .j a v a 2 s . c o m
    String positiveButtonText = "Yes";

    LinearLayout linearLayout = new LinearLayout(UIActivity.this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    alert.setTitle("Enable Auto-Load?");
    alert.setMessage(getString(R.string.auto_load_message));

    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction()
                    .setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right)
                    .replace(R.id.container, AutoLoadFragment.newInstance());
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
    });

    alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });
    alert.show();
}

From source file:com.codegarden.nativenavigation.JuceActivity.java

public final void showMessageBox(String title, String message, final long callback) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(title).setMessage(message).setCancelable(true).setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    JuceActivity.this.alertDismissed(callback, 0);
                }/*  w  w w  . ja va  2 s.co  m*/
            });

    builder.create().show();
}

From source file:com.hmatalonga.greenhub.ui.TaskListActivity.java

@TargetApi(21)
private void showPermissionInfoDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setMessage(getString(R.string.package_usage_permission_text))
            .setTitle(getString(R.string.package_usage_permission_title));

    builder.setPositiveButton(R.string.open_settings, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // User clicked OK button
            startActivity(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS));
        }//from  ww w. j  a  v  a  2s  . c o m
    });
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // User cancelled the dialog
            dialog.cancel();
        }
    });

    builder.create().show();
}

From source file:com.cypress.cysmart.RDKEmulatorView.MicrophoneEmulatorFragment.java

/**
 * Method to display a custom alert./*from   w  w w. ja v  a 2  s . co  m*/
 * Option for entering the google key in the method for voice to
 * text conversion
 */
private void showCustumAlert(String storedKey, boolean changeNeeded) {

    LayoutInflater li = LayoutInflater.from(getActivity());
    View promptsView = li.inflate(R.layout.api_key_dialog_alert, null);
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

    // set api_key_dialog_alert.xml to alertdialog builder
    alertDialogBuilder.setView(promptsView);

    //User input Edittext
    final EditText userInput = (EditText) promptsView.findViewById(R.id.custom_alert_user_input);
    if (changeNeeded) {
        userInput.setText(storedKey);
    }

    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // get user input and set it to sharedpreferecne
            Logger.i("userInput.getText()--->" + userInput.getText());
            Utils.setStringSharedPreference(getActivity(), Constants.PREF_GOOGLE_API_KEY,
                    userInput.getText().toString());
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    alertDialog.show();

}

From source file:com.codegarden.nativenavigation.JuceActivity.java

public final void showOkCancelBox(String title, String message, final long callback) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(title).setMessage(message).setCancelable(true)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    JuceActivity.this.alertDismissed(callback, 1);
                }//from  w  ww .  jav a  2 s  . c o  m
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    JuceActivity.this.alertDismissed(callback, 0);
                }
            });

    builder.create().show();
}

From source file:org.span.manager.MainActivity.java

@Override
protected Dialog onCreateDialog(int id, Bundle args) {
    Log.d(TAG, "onCreateDialog()"); // DEBUG
    if (id == ID_DIALOG_STARTING) {
        return onCreateDialog(id);
    } else if (id == ID_DIALOG_STOPPING) {
        return onCreateDialog(id);
    } else if (id == ID_DIALOG_CONNECTING) {
        return onCreateDialog(id);
    } else if (id == ID_DIALOG_CONFIG) {
        //Config load dialogue
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        final String filepath = args.getString("filepath");
        final String filename = filepath.substring(filepath.indexOf(':') + 3);
        builder.setMessage("Are you sure you want to load this external configuration file?\n" + filepath)
                .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        //Load the Configuration
                        String command = "cp " + filename + " /data/data/org.span/conf/manet.conf";
                        System.out.println(command);//debug
                        //CoreTask.runCommand(command);
                        app.manet.sendManetConfigLoadCommand(filename);
                        dialog.cancel();
                    }//from ww w.  ja  va  2  s.  c  o  m
                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        AlertDialog alert = builder.create();
        return alert;
    }
    return null;
}

From source file:com.codegarden.nativenavigation.JuceActivity.java

public final void showYesNoCancelBox(String title, String message, final long callback) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(title).setMessage(message).setCancelable(true)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    JuceActivity.this.alertDismissed(callback, 1);
                }//ww  w  .j  a  v  a2 s. c  o  m
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    JuceActivity.this.alertDismissed(callback, 2);
                }
            }).setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    JuceActivity.this.alertDismissed(callback, 0);
                }
            });

    builder.create().show();
}