Code example for Activity

Methods: getString

0
 
    public static AlertDialog.Builder newErrorDialog(final Activity activity, String title,
            Exception error) {
        String screenMessage = "";
        if (error instanceof ResourceMessageException) {
            screenMessage = activity.getString(((ResourceMessageException) error)
                    .getClientMessageResourceId()); 
        } else { 
            screenMessage = error.getLocalizedMessage();
        } 
 
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        builder.setTitle(title);
        builder.setMessage(screenMessage);
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.setCancelable(false);
        builder.setPositiveButton(activity.getString(android.R.string.ok), new OnClickListener() {
 
            @Override 
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            } 
        }); 
 
        return builder;
    } 
 
    public static AlertDialog.Builder newErrorDialog(final Activity activity, int titleId,
            Exception error) {
        return newErrorDialog(activity, activity.getString(titleId), error);
    } 
 
    /** 
     * Displays a error dialog with an exception's message as its body. Also displays a Send Email 
     * button to send the exception to the developer, if an appropriate Intent handler is available 
Contextual code suggestions in your IDE  Get Codota for Java