Example usage for android.app AlertDialog.Builder setMessage

List of usage examples for android.app AlertDialog.Builder setMessage

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setMessage.

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:com.github.socialc0de.gsw.android.MainActivity.java

/**
 * Handles the results from activities launched to select an account and to install Google Play
 * Services.//w  ww  . j  a va  2 s  .co  m
 */

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_ACCOUNT_PICKER:
        if (data != null && data.getExtras() != null) {
            String accountName = data.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME);
            if (accountName != null) {
                onSignedIn(accountName);
            }
        } else if (!SIGN_IN_REQUIRED) {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle(R.string.are_you_sure);
            alert.setMessage(R.string.not_all_features);
            alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    startMainActivity();
                }
            });
            alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
                }
            });
            alert.show();

        }
        break;
    case REQUEST_GOOGLE_PLAY_SERVICES:
        if (resultCode != Activity.RESULT_OK) {
            checkGooglePlayServicesAvailable();
        }
        break;
    }

    if (requestCode == REQUEST_CODE_PAYMENT) {
        if (resultCode == Activity.RESULT_OK) {
            PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
            if (confirm != null) {
                try {
                    Log.i(TAG, confirm.toJSONObject().toString(4));
                    Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));
                    /**
                     *  TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification
                     * or consent completion.
                     * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                     * for more details.
                     *
                     * For sample mobile backend interactions, see
                     * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
                     */
                    Toast.makeText(getApplicationContext(), "PaymentConfirmation info received from PayPal",
                            Toast.LENGTH_LONG).show();

                } catch (JSONException e) {
                    Log.e(TAG, "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i(TAG, "The user canceled.");
        } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
        }
    } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) {
        if (resultCode == Activity.RESULT_OK) {
            PayPalAuthorization auth = data
                    .getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION);
            if (auth != null) {
                try {
                    Log.i("FuturePaymentExample", auth.toJSONObject().toString(4));

                    String authorization_code = auth.getAuthorizationCode();
                    Log.i("FuturePaymentExample", authorization_code);

                    Toast.makeText(getApplicationContext(), "Future Payment code received from PayPal",
                            Toast.LENGTH_LONG).show();

                } catch (JSONException e) {
                    Log.e("FuturePaymentExample", "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i("FuturePaymentExample", "The user canceled.");
        } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i("FuturePaymentExample",
                    "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
        }
    } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) {
        if (resultCode == Activity.RESULT_OK) {
            PayPalAuthorization auth = data
                    .getParcelableExtra(PayPalProfileSharingActivity.EXTRA_RESULT_AUTHORIZATION);
            if (auth != null) {
                try {
                    Log.i("ProfileSharingExample", auth.toJSONObject().toString(4));

                    String authorization_code = auth.getAuthorizationCode();
                    Log.i("ProfileSharingExample", authorization_code);

                    Toast.makeText(getApplicationContext(), "Profile Sharing code received from PayPal",
                            Toast.LENGTH_LONG).show();

                } catch (JSONException e) {
                    Log.e("ProfileSharingExample", "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i("ProfileSharingExample", "The user canceled.");
        } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i("ProfileSharingExample",
                    "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
        }
    }
}

From source file:com.bwash.bwashcar.activities.CompanyActivity.java

/**
 * This method shows dialog with given title & message.
 * Also there is an option to pass onClickListener for positive & negative button.
 *
 * @param title                         - dialog title
 * @param message                       - dialog message
 * @param onPositiveButtonClickListener - listener for positive button
 * @param positiveText                  - positive button text
 * @param onNegativeButtonClickListener - listener for negative button
 * @param negativeText                  - negative button text
 *///from   w  w  w  .j ava2  s. c  om
protected void showAlertDialog(@Nullable String title, @Nullable String message,
        @Nullable DialogInterface.OnClickListener onPositiveButtonClickListener, @NonNull String positiveText,
        @Nullable DialogInterface.OnClickListener onNegativeButtonClickListener, @NonNull String negativeText) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setPositiveButton(positiveText, onPositiveButtonClickListener);
    builder.setNegativeButton(negativeText, onNegativeButtonClickListener);
    mAlertDialog = builder.show();
}

From source file:org.starfishrespect.myconsumption.android.ui.CreateAccountActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_account);

    editTextUsername = (EditText) findViewById(R.id.editTextUsername);
    editTextPassword = (EditText) findViewById(R.id.editTextPassword);
    editTextPassword2 = (EditText) findViewById(R.id.editTextPassword2);
    buttonCreateAccount = (Button) findViewById(R.id.buttonCreateAccount);
    buttonCreateAccount.setOnClickListener(new View.OnClickListener() {
        @Override/* w  ww .ja v  a  2 s  .c o  m*/
        public void onClick(View v) {
            if (!MiscFunctions.isOnline(CreateAccountActivity.this)) {
                MiscFunctions.makeOfflineDialog(CreateAccountActivity.this).show();
                return;
            }
            if (editTextUsername.getText().toString().equals("")
                    || editTextPassword.getText().toString().equals("")
                    || editTextPassword2.getText().toString().equals("")) {
                Toast.makeText(CreateAccountActivity.this,
                        getString(R.string.dialog_message_error_must_fill_all_fields), Toast.LENGTH_LONG)
                        .show();
                return;
            }

            if (!editTextPassword.getText().toString().equals(editTextPassword2.getText().toString())) {
                Toast.makeText(CreateAccountActivity.this, R.string.dialog_message_error_password_must_match,
                        Toast.LENGTH_LONG).show();
                return;
            }

            new AsyncTask<Void, Void, Integer>() {

                @Override
                protected Integer doInBackground(Void... params) {
                    return createAccount();
                }

                @Override
                protected void onPostExecute(Integer result) {
                    if (result == 0) {
                        setResult(RESULT_OK);
                        finish();
                    } else {
                        AlertDialog.Builder builder = new AlertDialog.Builder(CreateAccountActivity.this);
                        builder.setTitle(R.string.dialog_title_error);
                        builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });
                        switch (result) {
                        case SimpleResponseDTO.STATUS_ALREADY_EXISTS:
                            builder.setMessage(R.string.dialog_message_error_user_already_exists);
                            break;
                        default:
                            builder.setMessage("An error has occurred. You might want to "
                                    + "check your internet connection or contact the application provider.");
                            break;

                        }
                        builder.show();
                    }
                }
            }.execute();
        }
    });
}

From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java

private Dialog assignConfirmDialog(final Context context, String str, boolean startNewWeek) {

    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.remove_id, null);
    final CheckBox rm_check = (CheckBox) textEntryView.findViewById(R.id.rm_local);
    rm_check.setText(R.string.assign_new_week);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    if (startNewWeek) {
        builder.setView(textEntryView);//w ww .  j  a  v a2s .  c  o  m
    }
    builder.setCancelable(false);
    builder.setTitle(R.string.assign_confirm_title);
    builder.setMessage(str);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            editor.putString(Util.SP_LOGIN_KEY_USERID, asID.getText().toString());
            Log.d("here!!!", "id is " + asID.getText().toString());
            //format check

            editor.putString(Util.SP_LOGIN_KEY_USERPWD, "");
            editor.putString(Util.SP_LOGIN_KEY_STUDY_STARTTIME, "" + Calendar.getInstance().getTimeInMillis());
            editor.commit();

            //start new study week, if checked
            if (rm_check.isChecked()) {

                String UID = null;
                try {
                    UID = Util.encryption(context, asID.getText().toString());
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                ChangeStudyWeek changeStudyWeek = new ChangeStudyWeek();
                changeStudyWeek.execute(UID);
            }

            setHints();
            //continue with set user pin (8)
            setResult(Activity.RESULT_OK);
            finish();
        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            setHints();
        }
    });
    return builder.create();
}

From source file:gr.scify.newsum.ui.SearchViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_NORMAL
            & (getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_SMALL) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    }//from www.jav a  2  s .c  o  m
    SharedPreferences usertheme = getSharedPreferences("theme", 0);
    int newTheme = usertheme.getInt("theme", 2);
    Utils.onActivityCreateSetTheme(this, newTheme);

    SharedPreferences userlang = getSharedPreferences("lang", 0);
    String newlang = userlang.getString("lang", Locale.getDefault().getLanguage());
    Setlanguage.updateLanguage(getApplicationContext(), newlang);

    GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
    View inflate = getLayoutInflater().inflate(R.layout.view, null);
    gestureOverlayView.addView(inflate);
    gestureOverlayView.addOnGesturePerformedListener(this);
    gestureOverlayView.setGestureColor(Color.TRANSPARENT);
    gestureOverlayView.setUncertainGestureColor(Color.TRANSPARENT);
    gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
    if (!gestureLib.load()) {
        finish();
    }
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(gestureOverlayView);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

    ImageView title_image = (ImageView) findViewById(R.id.title_image);
    title_image.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.scify)));
            startActivity(browse);
        }

    });

    // setContentView(R.layout.view);
    // TODO: Add Loading dialog

    SharedPreferences setvmassage = getSharedPreferences("dialog", 0);
    boolean dialogShown = setvmassage.getBoolean("dialogShown", false);

    if (!dialogShown) {
        // prepare the alert box
        AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
        alertbox.setMessage(R.string.view_massage);
        alertbox.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {

            }
        });
        alertbox.setCancelable(false);
        alertbox.show();

        SharedPreferences.Editor editor = setvmassage.edit();
        editor.putBoolean("dialogShown", true);
        editor.commit();
    }

    // Init waiting dialog
    showWaitingDialog();

    initLayoutAndControls();

}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

private void successDialog(int i) {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());

    if (i == 2 || i == 3) {
        alertDialog.setTitle(" ? ");
        alertDialog.setMessage("? ?  ??");
    } else if (i == 1) {
        alertDialog.setTitle("  ");
        alertDialog.setMessage("? ?  ?");
    } else if (i == 4) {
        alertDialog.setTitle("  ");
        alertDialog.setMessage("? ? ?");
    }/* w  w  w. jav a2 s.c o m*/

    alertDialog.setIcon(R.drawable.ic_dialog_alert);

    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to invoke YES event
            dialog.cancel();
            getMyBeaconList();
        }
    });

    alertDialog.show();
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

private void failDialog(int i) {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());

    if (i == 2 || i == 3) {
        alertDialog.setTitle("  ? ");
        alertDialog.setMessage("? ? ");
    } else if (i == 1) {
        alertDialog.setTitle("   ");
        alertDialog.setMessage(" ? ");
    } else if (i == 4) {
        alertDialog.setTitle("  ");
        alertDialog.setMessage(" ? ");
    }//from w  w  w. ja v  a  2 s  .c o  m

    alertDialog.setIcon(R.drawable.fail);

    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to invoke YES event
            dialog.cancel();
        }
    });

    alertDialog.show();
}

From source file:com.timemachine.controller.ControllerActivity.java

private void buildDisconnectDialog() {
    AlertDialog.Builder disconnectDialogBuilder = new AlertDialog.Builder(ControllerActivity.this);
    disconnectDialogBuilder.setMessage("Are you sure you want to disconnect?");
    disconnectDialogBuilder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            disconnectController();//from  w w w. j  a va  2s  .  com
        }
    });
    disconnectDialogBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        }
    });
    disconnectDialog = disconnectDialogBuilder.create();
}

From source file:com.zira.registration.VehicleInformationActivity.java

public void onBackPressed() {

    AlertDialog.Builder alert = new AlertDialog.Builder(VehicleInformationActivity.this);
    alert.setTitle("Please confirm");
    alert.setMessage("Are you sure you don't want to save any changes?");
    alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

        @Override//w  w w .j a va 2 s.  c  o  m
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            for (int i = 0; i < regActivities.size(); i++) {
                regActivities.get(i).finish();
            }
        }
    });
    alert.setNegativeButton("Dismiss", null);
    alert.show();
    /*Intent intent = new Intent(VehicleInformationActivity.this,GetProfile.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(intent);*/

}

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();
                    }//ww  w .  j  av  a 2s  .  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;
}