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

The following examples show how to use android.app.AlertDialog#setMessage() . 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: 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 2
Source File: ClockDialogs.java    From TabletClock with MIT License 6 votes vote down vote up
static void about(Context context) {
	final SpannableString s = new SpannableString(
			context.getText(R.string.aboutText));
	Linkify.addLinks(s, Linkify.ALL);
	AlertDialog alertDialog;
	alertDialog = new AlertDialog.Builder(context).create();
	alertDialog.setTitle(context.getText(R.string.aboutTitle));
	alertDialog.setMessage(s);
	alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
			context.getText(R.string.aboutCloseButton),
			new Dialog.OnClickListener() {
				@Override
				public void onClick(final DialogInterface dialog,
						final int which) {
					try {
						finalize();
					} catch (final Throwable e) {
						e.printStackTrace();
					}
				}
			});
	alertDialog.show();
	((TextView) alertDialog.findViewById(android.R.id.message))
			.setMovementMethod(mMovementCheck);
}
 
Example 3
Source File: CameraBridgeViewBase.java    From faceswap 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 OpenCV-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 5
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 6
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 7
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 8
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 9
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 10
Source File: PermissionHelper.java    From justaline-android with Apache License 2.0 6 votes vote down vote up
/**
 * Show rationale for storage permissions
 *
 * @param activity the activity to show the rationale on (PlaybackActivity)
 */
private static void showStoragePermissionRationale(final Activity activity) {
    final AlertDialog
            alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setMessage(activity.getString(R.string.storage_permission_rationale));
    alertDialog.setButton(android.support.v7.app.AlertDialog.BUTTON_POSITIVE,
            activity.getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    requestStoragePermission(activity, true);
                }
            });

    alertDialog.show();
}
 
Example 11
Source File: CameraBridgeViewBase.java    From FaceDetectDemo 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 12
Source File: PermissionHelper.java    From justaline-android with Apache License 2.0 6 votes vote down vote up
/**
 * Show dialog with rationale for required permissions
 *
 * @param activity calling activity which the AlertDialog is shown on (PermissionsActivity)
 * @return the dialog that is shown
 */
private static AlertDialog showRequiredPermissionRationale(final Activity activity) {
    final AlertDialog
            alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle(activity.getString(R.string.title_activity_permissions));
    alertDialog.setMessage(activity.getString(R.string.initial_permissions_required));

    alertDialog.setButton(android.support.v7.app.AlertDialog.BUTTON_NEUTRAL,
            activity.getString(R.string.ask_me_again),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    requestRequiredPermissions(activity, true);
                }
            });

    alertDialog.setCancelable(false);
    alertDialog.show();

    return alertDialog;
}
 
Example 13
Source File: RuntimeErrorAlert.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
public static void alert(final Object context,
    final String message, final String title,final String buttonText) {
  Log.i("RuntimeErrorAlert", "in alert");
  AlertDialog alertDialog = new AlertDialog.Builder((Context) context).create();
  alertDialog.setTitle(title);
  alertDialog.setMessage(message);
  alertDialog.setButton(buttonText, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
      ((Activity) context).finish();
    }});
  if (message == null) {
    // Avoid passing null to Log.e, which would cause a NullPointerException.
    Log.e(RuntimeErrorAlert.class.getName(), "No error message available");
  } else {
    Log.e(RuntimeErrorAlert.class.getName(), message);
  }
  alertDialog.show();
}
 
Example 14
Source File: CameraBridgeViewBase.java    From Document-Scanner with GNU General Public License v3.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: BlurNavigationDrawerActivity.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.about) {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(getString(R.string.app_name));
        alertDialog.setIcon(android.R.drawable.ic_dialog_info);
        alertDialog.setMessage("Developed by Basilis Charalampakis\n\n" +
                "GitHub     : http://github.com/charbgr\n" +
                "Linkedin  : http://linkedin.com/in/charalampakisbasilis/");
        alertDialog.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
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: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public static void confirm(String message, Activity activity, Boolean cancelable, DialogInterface.OnClickListener listener) {
	AlertDialog dialog = new AlertDialog.Builder(activity).create();
	dialog.setTitle(activity.getString(R.string.title));
	dialog.setMessage(message);
	dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", listener);
	dialog.setButton(AlertDialog.BUTTON_NEGATIVE, "NO", listener);
	if(cancelable){dialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Cancel",listener);}
	dialog.show();
}
 
Example 18
Source File: ManagePatchesActivity.java    From MCPELauncher with Apache License 2.0 5 votes vote down vote up
public void preparePatchInfo(AlertDialog dialog, ContentListItem patch) {
	dialog.setTitle(patch.toString(getResources()));
	String patchInfo;
	try {
		patchInfo = getPatchInfo(patch);
	} catch (Exception e) {
		patchInfo = "Cannot show info: " + e.getStackTrace();
	}
	dialog.setMessage(patchInfo);
}
 
Example 19
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 20
Source File: SettingsActivity.java    From mytracks with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onPrepareDialog(int id, Dialog dialog, Bundle bundle) {
  if (id == DIALOG_CONFIRM_DRIVE_SYNC_ON) {
    AlertDialog alertDialog = (AlertDialog) dialog;
    String googleAccount = PreferencesUtils.getString(
        this, R.string.google_account_key, PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT);
    alertDialog.setMessage(getString(R.string.sync_drive_confirm_message, googleAccount,
        getString(R.string.my_tracks_app_name)));
  }
  super.onPrepareDialog(id, dialog, bundle);
}