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.google.zxing.client.android.result.ResultHandler.java

final void openGoogleShopper(String query) {

    // Construct Intent to launch Shopper
    Intent intent = new Intent(Intent.ACTION_SEARCH);
    intent.setClassName(GOOGLE_SHOPPER_PACKAGE, GOOGLE_SHOPPER_ACTIVITY);
    intent.putExtra(SearchManager.QUERY, query);

    // Is it available?
    PackageManager pm = activity.getPackageManager();
    Collection<?> availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

    if (availableApps != null && !availableApps.isEmpty()) {
        // If something can handle it, start it
        activity.startActivity(intent);/* w w  w .  j  av a  2 s.  c om*/
    } else {
        // Otherwise offer to install it from Market.
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        builder.setTitle(R.string.msg_google_shopper_missing);
        builder.setMessage(R.string.msg_install_google_shopper);
        builder.setIcon(R.drawable.shopper_icon);
        builder.setPositiveButton(R.string.button_ok, shopperMarketListener);
        builder.setNegativeButton(R.string.button_cancel, null);
        builder.show();
    }
}

From source file:se.anyro.tagtider.TransferActivity.java

private AlertDialog createC2dmDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.c2dm_dialog_title);
    builder.setMessage(R.string.c2dm_dialog_message);
    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override/*  w  w w  .ja va2 s . co  m*/
        public void onClick(DialogInterface dialog, int which) {
            if (mRegistrationId == null) {
                registerC2dm();
            } else {
                new StartSubscriptionTask().execute(mRegistrationId, TYPE_AC2DM);
            }
        }
    });
    builder.setNegativeButton("Avbryt", null);
    final AlertDialog smsDialog = builder.create();
    return smsDialog;
}

From source file:com.iss.android.wearable.datalayer.MainActivity.java

private void displaySWBatteryWarning() {
    // Display a cancelable warning that the HRM battery is running low.
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    String warning = "The Smartwatch battery charge is below 75%. Please charge it to ensure it lasts the night.";
    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(100);/*from w ww.j  a va  2  s.  c  o m*/
    builder.setMessage(warning).setTitle(R.string.battery_warning_title).setCancelable(true)
            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });

    AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:notused.Login.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);//from   ww w.ja v  a  2 s.  co  m

    txtEmail = (TextView) findViewById(R.id.email);
    txtPassword = (TextView) findViewById(R.id.password);
    btnLogin = (Button) findViewById(R.id.login);
    ckRememberMe = (CheckBox) findViewById(R.id.checkbox);
    txtForgotPassword = (TextView) findViewById(R.id.forgotPassword);
    txtSignUp = (TextView) findViewById(R.id.signUp);
    validator = new Validator();
    config = new Config(Login.this);
    dbAdapter = new UserDBAdapter(this);

    baseUrl = "http://lawpavilionstore.com/android/login";

    dbAdapter.open(DB_NAME);
    //TODO: remove drop table query
    dbAdapter.executeQuery("DROP TABLE IF EXISTS" + dbAdapter.TABLE_NAME + ";");
    //dbAdapter.createUserTable();

    Cursor cursor = dbAdapter.fetch("SELECT * from " + dbAdapter.TABLE_NAME);

    if (cursor != null) {
        //new user
        if (cursor.getCount() == 1) {

            String loggedOut = cursor.getString(cursor.getColumnIndex(dbAdapter.LOG_OUT));
            if (loggedOut.equalsIgnoreCase("0")) {
                //User not looged out..continue
                String token = cursor.getString(cursor.getColumnIndex(dbAdapter.TOKEN));
                Toast.makeText(Login.this, "Existing", Toast.LENGTH_SHORT).show();

                Login.this.finish();
                String set_up_status = cursor.getString(cursor.getColumnIndex(dbAdapter.SET_UP_STATUS));

                if (set_up_status.equalsIgnoreCase("pending")) {

                    Intent intent = new Intent(Login.this, Module.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                } else {
                    Intent intent = new Intent(Login.this, Dashboard.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                }

            } else {
                //user has been forced to login..
                SIGN_IN_TYPE = LOGGED_OUT_USER_TYPE;
            }
        } else {
            //New user account..
            SIGN_IN_TYPE = NEW_USER_TYPE;
        }
    } else {
        Toast.makeText(Login.this, "DB error", Toast.LENGTH_SHORT).show();
        //Do something here
    }
    dbAdapter.close();
    btnLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            _email = txtEmail.getText().toString().trim();
            _password = txtPassword.getText().toString().trim();
            boolean isFieldSet = true;

            if (!validator.isValidEmail(_email)) {

                txtEmail.setError(Validator.emailErrorMessage);
                isFieldSet = false;
            }

            if (validator.isEmpty(_password)) {
                txtPassword.setError(Validator.defaultErrorMessage);
                isFieldSet = false;
            }

            Toast.makeText(Login.this, "Ready for Async Task", Toast.LENGTH_SHORT).show();

            if (isFieldSet) {
                if (config.isConnectingToInternet()) {

                    AsyncLogin asyncLogin = new AsyncLogin();
                    asyncLogin.execute();
                } else {
                    AlertDialog.Builder builder = new AlertDialog.Builder(Login.this);
                    builder.setTitle("Error");
                    builder.setMessage("Oops! Something went wrong!\n\nplease check your internet connection")
                            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {

                                }
                            }).setPositiveButton("Retry", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    AsyncLogin asyncLogin = new AsyncLogin();
                                    asyncLogin.execute();
                                }
                            });
                    AlertDialog dialog = builder.create();
                    dialog.show();
                }

            } else {
                return;
            }

        }
    });
    txtForgotPassword.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Login.this, ForgotPassword.class);
            startActivity(intent);
        }
    });

    txtSignUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent intent = new Intent(Login.this, SignUp.class);
            startActivity(intent);
        }
    });

}

From source file:de.da_sense.moses.client.service.MosesService.java

/**
 * This function will be executed on first run and shows some welcome
 * dialog.//from   w w  w . ja va  2 s.  c  o  m
 * 
 * @param context
 *            The context under which the dialog is shown.
 */
private void showWelcomeDialog(final Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    builder.setIcon(R.drawable.ic_launcher);
    builder.setCancelable(false); // This blocks the 'BACK' button
    builder.setMessage(getString(R.string.welcome_to_moses_string));
    builder.setTitle(getString(R.string.welcome_to_moses_title_string));
    builder.setNegativeButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
    Log.d("MoSeS.SERVICE", "First login.");
    PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("first_start", false).commit();
}

From source file:com.mobicage.rogerthat.registration.YSAAARegistrationActivity.java

private void register() {
    mStatusLbl.setText(R.string.initializing);
    mProgressBar.setProgress(0);/*from w  ww .  j  a v a  2  s .  c  o  m*/
    mProgressBar.setVisibility(View.VISIBLE);

    TimerTask timerTask = new TimerTask() {
        @Override
        public void run() {
            mUIHandler.post(new SafeRunnable() {
                @Override
                protected void safeRun() throws Exception {
                    T.UI();
                    mProgressBar.setProgress(mProgressBar.getProgress() + 1);
                }
            });
        }
    };
    mTimer.scheduleAtFixedRate(timerTask, 250, 250);

    mRetryBtn.setVisibility(View.GONE);
    if (!mService.getNetworkConnectivityManager().isConnected()) {
        mTimer.cancel();
        mProgressBar.setVisibility(View.GONE);
        mStatusLbl.setText(R.string.registration_screen_instructions_check_network_not_available);
        mRetryBtn.setVisibility(View.VISIBLE);
        UIUtils.showNoNetworkDialog(this);
        return;
    }

    final SafeRunnable showErrorDialog = new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            T.UI();
            AlertDialog.Builder builder = new AlertDialog.Builder(YSAAARegistrationActivity.this);
            builder.setMessage(R.string.error_please_try_again);
            builder.setPositiveButton(R.string.rogerthat, null);
            AlertDialog dialog = builder.create();
            dialog.show();

            mTimer.cancel();
            mProgressBar.setVisibility(View.GONE);
            mStatusLbl.setText(R.string.error_please_try_again);
            mRetryBtn.setVisibility(View.VISIBLE);
        }
    };

    final String timestamp = "" + mWiz.getTimestamp();
    final String deviceId = mWiz.getDeviceId();
    final String registrationId = mWiz.getRegistrationId();
    final String installId = mWiz.getInstallationId();

    mWorkerHandler.post(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            T.REGISTRATION();
            String version = "1";
            String signature = Security.sha256(
                    version + " " + installId + " " + timestamp + " " + deviceId + " " + registrationId + " "
                            + CloudConstants.APP_SERVICE_GUID + CloudConstants.REGISTRATION_MAIN_SIGNATURE);

            HttpPost httppost = new HttpPost(CloudConstants.REGISTRATION_YSAAA_URL);
            try {
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(13);
                nameValuePairs.add(new BasicNameValuePair("version", version));
                nameValuePairs.add(new BasicNameValuePair("platform", "android"));
                nameValuePairs.add(new BasicNameValuePair("registration_time", timestamp));
                nameValuePairs.add(new BasicNameValuePair("device_id", deviceId));
                nameValuePairs.add(new BasicNameValuePair("registration_id", registrationId));
                nameValuePairs.add(new BasicNameValuePair("signature", signature));
                nameValuePairs.add(new BasicNameValuePair("install_id", installId));
                nameValuePairs.add(new BasicNameValuePair("service", CloudConstants.APP_SERVICE_GUID));
                nameValuePairs.add(new BasicNameValuePair("language", Locale.getDefault().getLanguage()));
                nameValuePairs.add(new BasicNameValuePair("country", Locale.getDefault().getCountry()));
                nameValuePairs.add(new BasicNameValuePair("app_id", CloudConstants.APP_ID));
                nameValuePairs.add(
                        new BasicNameValuePair("use_xmpp_kick", CloudConstants.USE_XMPP_KICK_CHANNEL + ""));
                nameValuePairs.add(new BasicNameValuePair("GCM_registration_id", mGCMRegistrationId));
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                // Execute HTTP Post Request
                HttpResponse response = mHttpClient.execute(httppost);

                int statusCode = response.getStatusLine().getStatusCode();
                HttpEntity entity = response.getEntity();

                if (entity == null) {
                    mUIHandler.post(showErrorDialog);
                    return;
                }

                @SuppressWarnings("unchecked")
                final Map<String, Object> responseMap = (Map<String, Object>) JSONValue
                        .parse(new InputStreamReader(entity.getContent()));

                if (statusCode != 200 || responseMap == null) {
                    if (statusCode == 500 && responseMap != null) {
                        final String errorMessage = (String) responseMap.get("error");
                        if (errorMessage != null) {
                            mUIHandler.post(new SafeRunnable() {
                                @Override
                                protected void safeRun() throws Exception {
                                    T.UI();
                                    AlertDialog.Builder builder = new AlertDialog.Builder(
                                            YSAAARegistrationActivity.this);
                                    builder.setMessage(errorMessage);
                                    builder.setPositiveButton(R.string.rogerthat, null);
                                    AlertDialog dialog = builder.create();
                                    dialog.show();

                                    mTimer.cancel();
                                    mProgressBar.setVisibility(View.GONE);
                                    mStatusLbl.setText(errorMessage);
                                    mRetryBtn.setVisibility(View.VISIBLE);
                                }
                            });
                            return;
                        }
                    }
                    mUIHandler.post(showErrorDialog);
                    return;
                }
                JSONObject account = (JSONObject) responseMap.get("account");
                final String email = (String) responseMap.get("email");
                final RegistrationInfo info = new RegistrationInfo(email,
                        new Credentials((String) account.get("account"), (String) account.get("password")));
                mUIHandler.post(new SafeRunnable() {
                    @Override
                    protected void safeRun() throws Exception {
                        T.UI();
                        mWiz.setEmail(email);
                        mWiz.save();
                        tryConnect(1, getString(R.string.registration_establish_connection, email,
                                getString(R.string.app_name)) + " ", info);
                    }
                });

            } catch (Exception e) {
                L.d(e);
                mUIHandler.post(showErrorDialog);
            }
        }
    });
}

From source file:com.andybotting.tramhunter.activity.StopDetailsActivity.java

/**
 * Show a dialog message for a given 'Special Event'
 * @param message//from   w  ww  . j  av  a 2  s. co m
 */
private void showSpecialEvent(String message) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setTitle("Special Event");
    dialogBuilder.setMessage(message);
    dialogBuilder.setPositiveButton("OK", null);
    dialogBuilder.setIcon(R.drawable.ic_dialog_alert);
    dialogBuilder.show();
}

From source file:com.remobile.dialogs.Notification.java

/**
 * Builds and shows a native Android confirm dialog with given title, message, buttons.
 * This dialog only shows up to 3 buttons.  Any labels after that will be ignored.
 * The index of the button pressed will be returned to the JavaScript callback identified by callbackId.
 *
 * @param message         The message the dialog should display
 * @param title           The title of the dialog
 * @param buttonLabels    A comma separated list of button labels (Up to 3 buttons)
 * @param callbackContext The callback context.
 *//*from w  w  w .j a v  a  2  s .com*/
public synchronized void confirm(final String message, final String title, final JSONArray buttonLabels,
        final CallbackContext callbackContext) {
    Runnable runnable = new Runnable() {
        public void run() {
            AlertDialog.Builder dlg = createDialog(); // new AlertDialog.Builder(this.cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);

            // First button
            if (buttonLabels.length() > 0) {
                try {
                    dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1));
                        }
                    });
                } catch (JSONException e) {
                }
            }

            // Second button
            if (buttonLabels.length() > 1) {
                try {
                    dlg.setNeutralButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2));
                        }
                    });
                } catch (JSONException e) {
                }
            }

            // Third button
            if (buttonLabels.length() > 2) {
                try {
                    dlg.setPositiveButton(buttonLabels.getString(2), new AlertDialog.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3));
                        }
                    });
                } catch (JSONException e) {
                }
            }
            dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    dialog.dismiss();
                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
                }
            });

            changeTextDirection(dlg);
        }

        ;
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}

From source file:goo.TeaTimer.TimerActivity.java

/** {@inheritDoc} */
@Override//from   w  w w  .  jav a  2  s  .  c om
protected Dialog onCreateDialog(int id) {
    Dialog d = null;

    switch (id) {

    case NUM_PICKER_DIALOG: {
        int[] timeVec = TimerUtils.time2Mhs(mLastTime);
        int[] init = { timeVec[0], timeVec[1], timeVec[2] };
        int[] inc = { 1, 1, 1 };
        int[] start = { 0, 0, 0 };
        int[] end = { 23, 59, 59 };
        String[] sep = { ":", ".", "" };

        NumberPicker.Formatter[] format = { NumberPicker.TWO_DIGIT_FORMATTER, NumberPicker.TWO_DIGIT_FORMATTER,
                NumberPicker.TWO_DIGIT_FORMATTER };

        d = new NNumberPickerDialog(this, this, getResources().getString(R.string.InputTitle), init, inc, start,
                end, sep, format);
    }
        break;

    case ALERT_DIALOG: {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(getResources().getText(R.string.warning_text)).setCancelable(false)
                .setPositiveButton(getResources().getText(R.string.warning_button), null)
                .setTitle(getResources().getText(R.string.warning_title));

        d = builder.create();

    }
        break;
    }

    return d;
}

From source file:li.barter.fragments.ChatsFragment.java

@Override
public void onDialogClick(final DialogInterface dialog, final int which) {

    if ((mChatDialogFragment != null) && mChatDialogFragment.getDialog().equals(dialog)) {

        if (which == 0) {

            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

            // set title
            alertDialogBuilder.setTitle("Confirm");

            // set dialog message
            alertDialogBuilder.setMessage(getResources().getString(R.string.delete_chat_alert_message))
                    .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int id) {

                            deleteChat(mDeleteChatId);
                            dialog.dismiss();
                        }/*  ww w  .  ja  v  a  2  s  .co m*/
                    }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int id) {
                            // if this button is clicked, just close
                            // the dialog box and do nothing
                            dialog.cancel();
                        }
                    });

            // create alert dialog
            final AlertDialog alertDialog = alertDialogBuilder.create();

            // show it
            alertDialog.show();

        } else if (which == 1) {

            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

            // set title
            alertDialogBuilder.setTitle("Confirm");

            // set dialog message
            alertDialogBuilder.setMessage(getResources().getString(R.string.block_user_alert_message))
                    .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int id) {

                            blockUser(mBlockUserId);
                            dialog.dismiss();
                        }
                    }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int id) {
                            // if this button is clicked, just close
                            // the dialog box and do nothing
                            dialog.cancel();
                        }
                    });

            // create alert dialog
            final AlertDialog alertDialog = alertDialogBuilder.create();

            // show it
            alertDialog.show();

        }
    } else {
        super.onDialogClick(dialog, which);
    }
}