Java Code Examples for android.app.AlertDialog#setButton()

The following examples show how to use android.app.AlertDialog#setButton() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraBridgeViewBase.java    From MOAAP with MIT License 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 2
Source File: CommonGUI.java    From microbit with Apache License 2.0 6 votes vote down vote up
public static void commonAlertDialog(Context parent, String title, String message) {

        AlertDialog alertDialog = new AlertDialog.Builder(parent, AlertDialog.THEME_HOLO_DARK).create();
        alertDialog.setTitle(title);

        alertDialog.setMessage(Html.fromHtml(message));
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }
        );

        alertDialog.show();
    }
 
Example 3
Source File: CameraBridgeViewBase.java    From sudokufx with Apache License 2.0 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 4
Source File: CameraBridgeViewBase.java    From Android-Car-duino with GNU General Public License v2.0 6 votes vote down vote up
private void onEnterStartedState() {
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 5
Source File: CameraBridgeViewBase.java    From Machine-Learning-Projects-for-Mobile-Applications with MIT License 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 6
Source File: CameraBridgeViewBase.java    From react-native-documentscanner-android with MIT License 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 7
Source File: CameraBridgeViewBase.java    From MOAAP with MIT License 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 8
Source File: PdfActivity.java    From Reader with Apache License 2.0 6 votes vote down vote up
@Override
public void onBackPressed() {
    if (core != null && core.hasChanges()) {
        mAlertBuilder = new AlertDialog.Builder(mContext);
        DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                if (which == AlertDialog.BUTTON_POSITIVE)
                    core.save();

                finish();
            }
        };
        AlertDialog alert = mAlertBuilder.create();
        alert.setTitle("MuPDF");
        alert.setMessage(getString(R.string.document_has_changes_save_them_));
        alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.yes), listener);
        alert.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.no), listener);
        alert.show();
    } else {
        super.onBackPressed();
    }
}
 
Example 9
Source File: CameraBridgeViewBase.java    From MOAAP with MIT License 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 10
Source File: CameraBridgeViewBase.java    From Image-Detection-Samples with Apache License 2.0 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 11
Source File: CameraBridgeViewBase.java    From Form-N-Fun with MIT License 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 12
Source File: CameraBridgeViewBase.java    From AndroidDocumentScanner with MIT License 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 13
Source File: CameraBridgeViewBase.java    From LPR with Apache License 2.0 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 14
Source File: CameraBridgeViewBase.java    From opencv-documentscanner-android with Apache License 2.0 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 15
Source File: QuestionWidget.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
/**
 * Display extra help, triggered by user request.
 */
private void fireHelpText(final Runnable r) {
    if (!mPrompt.hasHelp()) {
        return;
    }

    // Depending on ODK setting, help may be displayed either as
    // a dialog or inline, underneath the question text

    if (showHelpWithDialog()) {
        AlertDialog mAlertDialog = new AlertDialog.Builder(this.getContext()).create();
        ScrollView scrollView = new ScrollView(this.getContext());
        scrollView.addView(createHelpLayout());
        mAlertDialog.setView(scrollView);

        DialogInterface.OnClickListener errorListener = (dialog, i) -> {
            switch (i) {
                case DialogInterface.BUTTON1:
                    dialog.cancel();
                    if (r != null) r.run();
                    break;
            }
        };
        mAlertDialog.setCancelable(true);
        mAlertDialog.setButton(StringUtils.getStringSpannableRobust(this.getContext(), R.string.ok), errorListener);
        mAlertDialog.show();
    } else {

        if (helpPlaceholder.getVisibility() == View.GONE) {
            expand(helpPlaceholder);
        } else {
            collapse(helpPlaceholder);
        }
    }
}
 
Example 16
Source File: MainActivity.java    From android-kubernetes-blockchain with Apache License 2.0 5 votes vote down vote up
public void saveUser(String result) {
    ResultOfEnroll resultOfEnroll = gson.fromJson(result, ResultOfEnroll.class);
    Log.d(TAG, resultOfEnroll.result.user);


    editor = sharedPreferences.edit();

    editor.putString("BlockchainUserId",resultOfEnroll.result.user);
    editor.apply();

    sendToMongo(resultOfEnroll.result.user);

    // send user id to registeree-api

    // save the user name

    AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
    alertDialog.setTitle("Enrollment successful!");
    alertDialog.setMessage("You have been enrolled to the blockchain network. Your User ID is:\n\n" + resultOfEnroll.result.user);
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "CONFIRM",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 17
Source File: AlertDialogManager.java    From apigee-android-sdk with Apache License 2.0 5 votes vote down vote up
public void showAlertDialog(Context context, String title, String message) {

    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(message);

    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which) {
      }
    });

    alertDialog.show();
  }
 
Example 18
Source File: MainFragment.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 5 votes vote down vote up
private void showOkAlert(final String title, final String detail)
{
   AlertDialog alertDialog = new AlertDialog.Builder(getActivity(), R.style.SimpleAlertStyle).create();
   alertDialog.setTitle(title);
   alertDialog.setMessage(detail);
   alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which)
      {
         dialog.dismiss();
      }
   });
   alertDialog.show();
}
 
Example 19
Source File: StartFragment.java    From traccar-manager-android with Apache License 2.0 5 votes vote down vote up
private void onError() {
    startButton.setEnabled(true);

    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setMessage(getString(R.string.error_connection));
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(android.R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 20
Source File: FileActivity.java    From lrkFM with MIT License 5 votes vote down vote up
/**
 * Launches a prompt to create a new directory.
 */
private void launchNewDirDialog() {
    AlertDialog newDirDialog = new AlertDialog.Builder(this)
            .setNegativeButton(R.string.cancel, (dialogInterface, i) -> Log.d(TAG, "Cancel pressed"))
            .setTitle(R.string.new_directory)
            .setView(R.layout.layout_name_prompt)
            .create();
    newDirDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.okay), (d, i) -> {
        String newDirName = currentDirectory + File.separator + ((EditText) newDirDialog.findViewById(R.id.destinationName)).getText().toString();
        newDir(new File(newDirName));
        reloadCurrentDirectory();
    });
    newDirDialog.show();
}