android.app.AlertDialog#setMessage ( )源码实例Demo

下面列出了android.app.AlertDialog#setMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: sudokufx   文件: CameraBridgeViewBase.java
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();

    }
}
 
@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);
}
 
源代码3 项目: Document-Scanner   文件: CameraBridgeViewBase.java
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();

    }
}
 
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();
}
 
源代码5 项目: justaline-android   文件: PermissionHelper.java
/**
 * 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;
}
 
源代码6 项目: FaceDetectDemo   文件: CameraBridgeViewBase.java
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();

    }
}
 
源代码7 项目: justaline-android   文件: PermissionHelper.java
/**
 * 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();
}
 
源代码8 项目: Reader   文件: PdfActivity.java
@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();
    }
}
 
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();

    }
}
 
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();

    }
}
 
源代码11 项目: MOAAP   文件: CameraBridgeViewBase.java
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();

    }
}
 
源代码12 项目: MOAAP   文件: CameraBridgeViewBase.java
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();

    }
}
 
源代码13 项目: OpenCV-android   文件: CameraBridgeViewBase.java
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();

    }
}
 
源代码14 项目: faceswap   文件: CameraBridgeViewBase.java
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();

    }
}
 
源代码15 项目: TabletClock   文件: ClockDialogs.java
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);
}
 
源代码16 项目: mytracks   文件: SettingsActivity.java
@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);
}
 
源代码17 项目: apigee-android-sdk   文件: AlertDialogManager.java
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();
  }
 
源代码18 项目: MCPELauncher   文件: ManagePatchesActivity.java
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);
}
 
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();
}
 
源代码20 项目: BotLibre   文件: MainActivity.java
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();
}