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.houseofslack.pullscoring.Scoring.java

public void clickGoUndo(View unused) {
    int team0Score = getScore(R.id.left_score_input);
    int team1Score = getScore(R.id.right_score_input);

    // if both scores are 0, this is an undo, not a go
    // but, if there are no scores, do nothing
    if ((team0Score == 0) && (team1Score == 0)) {
        // attempted undo, check for any scores in the list
        if (!team0Scores.isEmpty() && !team1Scores.isEmpty()) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage(R.string.undo_confirm_message);
            builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override/*w w  w .ja  v  a  2  s  .  co m*/
                public void onClick(DialogInterface arg0, int arg1) {
                    // remove the last scores from the list
                    team0Scores.remove(team0Scores.size() - 1);
                    team1Scores.remove(team1Scores.size() - 1);
                    redrawScores();
                    // make sure we update the button in the middle
                    setGoButtonCaption();
                    // make sure the first input is selected
                    clickLeftInput(null);
                }
            });
            builder.setNegativeButton(R.string.cancel, null);
            builder.show();
        }
    } else {
        // we have scores (at least one), add them to the lists, clear the strings,
        // and then redraw
        team0Scores.add(team0Score);
        team1Scores.add(team1Score);
        clearScores();
        redrawScores();
        // make sure we update the button in the middle
        setGoButtonCaption();
        // make sure the first input is selected
        clickLeftInput(null);
    }
}

From source file:com.bt.heliniumstudentapp.UpdateClass.java

@Override
protected void onPostExecute(String html) {
    if (html != null) {
        try {/*  w  w w.j a  va 2 s  .c  o m*/
            final JSONObject json = (JSONObject) new JSONTokener(html).nextValue();

            versionName = json.optString("version_name");
            final int versionCode = json.optInt("version_code");

            try {
                final int currentVersionCode = context.getPackageManager()
                        .getPackageInfo(context.getPackageName(), 0).versionCode;

                if (versionCode > currentVersionCode) {
                    if (!settings)
                        updateDialog.show();

                    updateDialog.setTitle(context.getString(R.string.update) + ' ' + versionName);

                    final TextView contentTV = (TextView) updateDialog.findViewById(R.id.tv_content_du);
                    contentTV.setTextColor(ContextCompat.getColor(context, MainActivity.themePrimaryTextColor));
                    contentTV.setText(Html.fromHtml(json.optString("content"), null, new Html.TagHandler() {

                        @Override
                        public void handleTag(boolean opening, String tag, Editable output,
                                XMLReader xmlReader) {
                            if ("li".equals(tag))
                                if (opening)
                                    output.append(" \u2022 ");
                                else
                                    output.append("\n");
                        }
                    }));

                    updateDialog.setCanceledOnTouchOutside(true);

                    updateDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);

                    updateDialog.getButton(AlertDialog.BUTTON_POSITIVE)
                            .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor));
                } else if (settings) {
                    updateDialog.setTitle(context.getString(R.string.update_no));

                    final TextView contentTV = (TextView) updateDialog.findViewById(R.id.tv_content_du);
                    contentTV.setTextColor(ContextCompat.getColor(context, MainActivity.themePrimaryTextColor));
                    contentTV.setText(Html.fromHtml(json.optString("content"), null, new Html.TagHandler() {

                        @Override
                        public void handleTag(boolean opening, String tag, Editable output,
                                XMLReader xmlReader) {
                            if ("li".equals(tag))
                                if (opening)
                                    output.append(" \u2022 ");
                                else
                                    output.append("\n");
                        }
                    }));

                    updateDialog.setCanceledOnTouchOutside(true);
                }
            } catch (NameNotFoundException e) {
                Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show();
            }
        } catch (JSONException e) {
            Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show();
        }
    } else if (settings) {
        updateDialog.cancel();

        final AlertDialog.Builder updateDialogBuilder = new AlertDialog.Builder(
                new ContextThemeWrapper(context, MainActivity.themeDialog));

        updateDialogBuilder.setTitle(context.getString(R.string.update));

        updateDialogBuilder.setMessage(R.string.error_update);

        updateDialogBuilder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                downloadAPK();
            }
        });

        updateDialogBuilder.setNegativeButton(android.R.string.no, null);

        final AlertDialog updateDialog = updateDialogBuilder.create();

        updateDialog.setCanceledOnTouchOutside(true);
        updateDialog.show();

        updateDialog.getButton(AlertDialog.BUTTON_POSITIVE)
                .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor));
        updateDialog.getButton(AlertDialog.BUTTON_NEGATIVE)
                .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor));
    }
}

From source file:com.meycup.ducksound.BackgroundSearch.java

@Override
protected void onPostExecute(final String[][] strings) {
    if (strings[0][0].equals("error_on_search")) {

        if (strings[0][1].equals("")) {

            tv.setVisibility(View.VISIBLE);
            listView.setAdapter(null);// w w w.  j a  va 2  s.co  m

        } else {

            AlertDialog.Builder alert = new AlertDialog.Builder(context);

            alert.setTitle("Ocorreu um erro!");
            alert.setMessage(strings[0][1]);

            alert.setPositiveButton("Tentar novamente", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    BackgroundSearch research = new BackgroundSearch(context, listView, play_bar, tv);
                    research.execute(search);
                    dialog.dismiss();
                }
            });

            alert.setNegativeButton("Sair", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    System.exit(0);
                }
            });

            alert.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

            alert.show();
        }

    } else {

        if (tv != null) {
            tv.setVisibility(View.INVISIBLE);
        }

        int count = 0;
        for (int i = 0; i < strings[0].length; i++) {
            if (strings[0][i] != null) {
                count++;
            }
        }

        ListAdapter adp = new ListAdapter(context, strings, new String[count]);
        listView.setAdapter(adp);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (strings[position + 1][6].equals("true")) {
                    try {
                        if (player != null) {
                            player.stop();
                            player = new Player(play_bar, strings[position + 1][2], strings[0][position],
                                    (!strings[position + 1][4].equals("null")) ? strings[position + 1][4]
                                            : strings[position + 1][3],
                                    true);
                        } else {
                            player = new Player(play_bar, strings[position + 1][2], strings[0][position],
                                    (!strings[position + 1][4].equals("null")) ? strings[position + 1][4]
                                            : strings[position + 1][3],
                                    true);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } else {
                    AlertDialog.Builder alert = new AlertDialog.Builder(context);
                    alert.setMessage("Desculpe, no  possvel reproduzir essa msica, escolha outra.");
                    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });

                    alert.show();
                }

            }
        });
    }

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            if (strings[position + 1][6].equals("true")) {
                File dir = new File(Environment.getExternalStorageDirectory() + "/Ducksound");

                if (!dir.exists()) {
                    dir.mkdirs();
                }

                final DownloadManager DM = (DownloadManager) context.getSystemService(context.DOWNLOAD_SERVICE);

                String download_url;

                if (strings[position + 1][0].equals("true")) {
                    download_url = strings[position + 1][5] + "?client_id=" + MainActivity.CLIENT_ID;
                } else {
                    download_url = "http://188.138.17.231/~krafta/dow.php?url=" + strings[position + 1][2]
                            + "?client_id=" + MainActivity.CLIENT_ID + "&name="
                            + URLEncoder.encode(strings[0][position] + "(Ducksound)");
                }

                Uri uri = Uri.parse(download_url.replace("https://", "http://"));

                final DownloadManager.Request request = new DownloadManager.Request(uri);

                request.setAllowedNetworkTypes(
                        DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
                        .setAllowedOverRoaming(false).setTitle(strings[0][position])
                        .setDestinationInExternalPublicDir("/Ducksound",
                                strings[0][position].replace(" ", "_").replace(",", "_").replace("", "c")
                                        .replace("'", "_") + " ("
                                        + context.getResources().getString(R.string.app_name) + ").mp3");

                AlertDialog.Builder download = new AlertDialog.Builder(context);

                download.setTitle("Baixar \"" + strings[0][position] + "\"?");
                download.setMessage("Tem certeza que deseja baixar essa msica?\nEla ser salva em "
                        + Environment.getExternalStorageDirectory().getAbsolutePath() + "/Ducksound");

                download.setPositiveButton("Baixar", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        DM.enqueue(request);
                        dialogInterface.dismiss();
                    }
                });

                download.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).show();

            } else {
                AlertDialog.Builder alert = new AlertDialog.Builder(context);
                alert.setMessage("Desculpe, no  possvel baixar essa msica, escolha outra.");
                alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });

                alert.show();
            }

            return true;
        }
    });

    progress.hide();
}

From source file:com.otaupdater.SettingsActivity.java

@Override
@SuppressWarnings("deprecation")
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference == accountPref) {
        showAccountDialog();//from  w w w.j a v  a  2 s. c  om
    } else if (preference == notifPref) {
        cfg.setShowNotif(notifPref.isChecked());
    } else if (preference == wifidlPref) {
        cfg.setWifiOnlyDl(wifidlPref.isChecked());
    } else if (preference == autodlPref) {
        if (cfg.hasProKey()) {
            cfg.setAutoDlState(autodlPref.isChecked());
        } else {
            Utils.showProKeyOnlyFeatureDialog(this, this);
            cfg.setAutoDlState(false);
            autodlPref.setChecked(false);
        }
    } else if (preference == resetWarnPref) {
        cfg.clearIgnored();
    } else if (preference == prokeyPref) {
        if (cfg.hasProKey()) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            if (cfg.isKeyRedeemCode()) {
                builder.setMessage(R.string.prokey_redeemed_thanks);
            } else {
                builder.setMessage(R.string.prokey_thanks);
            }

            builder.setNeutralButton(R.string.close, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

            final AlertDialog dlg = builder.create();
            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();
        } else {
            showGetProKeyDialog();
        }
    } else if (preference == donatePref) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Config.SITE_BASE_URL + Config.DONATE_URL)));
    } else {
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    }

    return true;
}

From source file:com.webileapps.fragments.CordovaFragment.java

/**
 * Display an error dialog and optionally exit application.
 */// w  w w  .  j  ava  2s . c  o m
public void displayError(final String title, final String message, final String button, final boolean exit) {
    final CordovaFragment me = this;
    me.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            try {
                AlertDialog.Builder dlg = new AlertDialog.Builder(me.getActivity());
                dlg.setMessage(message);
                dlg.setTitle(title);
                dlg.setCancelable(false);
                dlg.setPositiveButton(button, new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        if (exit) {
                            getActivity().finish();
                        }
                    }
                });
                dlg.create();
                dlg.show();
            } catch (Exception e) {
                getActivity().finish();
            }
        }
    });
}

From source file:de.quadrillenschule.azocamsynca.job.JobProcessor.java

public void doTestShots(final TriggerPhotoSerie job) {
    final NikonIR camera = ((AzoTriggerServiceApplication) getActivity().getApplication()).getCamera();
    final JobProcessor jobProcessor = ((AzoTriggerServiceApplication) getActivity().getApplication())
            .getJobProcessor();/*from   www  . j  a  v  a  2s .  c om*/

    final AlertDialog.Builder adb = new AlertDialog.Builder(getActivity(), R.style.dialog);
    job.setTriggerStatus(PhotoSerie.TriggerJobStatus.WAITFORUSER);
    adb.setTitle("Test Shots");
    adb.setMessage("This series collects all images during preparation of the project\n" + job.getProject()
            + "\n" + "Camera controls time: " + camera.isExposureSetOnCamera(job.getExposure()));
    if (!job.isToggleIsOpen()) {
        adb.setPositiveButton("Finish", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                job.setTriggerStatus(PhotoSerie.TriggerJobStatus.FINISHED_TRIGGERING);
                jobProcessor.fireJobProgressEvent(job);
                processingLoop();
            }
        });
    }

    adb.setNegativeButton("Trigger", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            camera.trigger();
            if (!camera.isExposureSetOnCamera(job.getExposure())) {
                job.setToggleIsOpen(!job.isToggleIsOpen());

                if (!job.isToggleIsOpen()) {
                    job.setNumber(job.getNumber() + 1);
                    job.setTriggered(job.getTriggered() + 1);

                }

            } else {
                job.setNumber(job.getNumber() + 1);
                job.setTriggered(job.getTriggered() + 1);
            }
            doTestShots(job);
        }
    });
    MediaPlayer mediaPlayer = MediaPlayer.create(activity, R.raw.oida_peda);
    mediaPlayer.start();
    // adb.create().show();
    adb.create();

    alertDialog = adb.show();
}

From source file:uk.bowdlerize.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    getActionBar().setTitle(getString(R.string.actionBarTitle));
    getActionBar().setSubtitle(getString(R.string.actionBarSubtitle));

    settings = getGCMPreferences(this);

    //Check if the user has agreed
    if (settings.getBoolean("agreed", false)) {
        onConfirmed();//from  www.j  av  a2 s.c  om
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.warningMessage).setTitle(R.string.warningTitle);
        builder.setPositiveButton(R.string.warningAgree, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                SharedPreferences.Editor editor = settings.edit();
                editor.putBoolean("agreed", true);
                editor.commit();
                dialog.dismiss();
                Toast.makeText(MainActivity.this, getString(R.string.warningAgreed), Toast.LENGTH_SHORT).show();
                configureTabs();
            }
        });
        builder.setNegativeButton(R.string.warningExit, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
                finish();
            }
        });
        builder.show();
    }
}

From source file:com.hybris.mobile.app.commerce.adapter.CartProductListAdapter.java

/**
 * Display the delete item dialog/* ww w . j a  v  a 2s  . c  o  m*/
 *
 * @param positionToDelete
 */
private void showDeleteItemDialog(final int positionToDelete) {

    // Creating the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(
            new ContextThemeWrapper(getContext(), R.style.AlertDialogCustom));
    builder.setMessage(R.string.cart_menu_delete_item_confirmation_title).setPositiveButton(
            R.string.cart_menu_delete_item_remove_button, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    QueryCartEntry queryCartEntry = new QueryCartEntry();
                    queryCartEntry.setEntryNumber(positionToDelete + "");

                    CommerceApplication.getContentServiceHelper()
                            .deleteCartEntry(new ResponseReceiver<CartModification>() {
                                @Override
                                public void onResponse(Response<CartModification> response) {
                                    updateCart();
                                }

                                @Override
                                public void onError(Response<ErrorList> response) {
                                    UIUtils.showError(response, getContext());

                                    // Update the cart
                                    SessionHelper.updateCart(getContext(), mRequestId, false);
                                }
                            }, mRequestId, queryCartEntry, null, false, null, mOnRequestListener);
                }
            }).setNegativeButton(R.string.cancel, null);

    AlertDialog alert = builder.create();

    // The dialog is cancelable by 3 ways: cancel button, click outside the dialog, click on the back button
    alert.setCancelable(true);
    alert.setCanceledOnTouchOutside(true);
    alert.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            // We revert to the default quantity when we dismiss the dialog
            if (mSelectedQuantity != null) {
                mSelectedQuantity.getEditText().clearFocus();
                mSelectedQuantity.getEditText().setText(mSelectedQuantity.getDefaultValue() + "");
            }
        }
    });

    alert.show();
}

From source file:com.kuaichumen.whistle.admin.CaptureActivity.java

private void displayFrameworkBugMessageAndExit() {
    // camera error
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(com.kuaichumen.whistle.R.string.app_name));
    builder.setMessage("???");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {

        @Override//w ww . ja  v  a2s.c o  m
        public void onClick(DialogInterface dialog, int which) {
            finish();
        }

    });
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            finish();
        }
    });
    builder.show();
}

From source file:com.openerp.addons.note.EditNoteFragment.java

public void openDailogview(String title, String message, String positivebtnText, String negativebtnText) {

    AlertDialog.Builder deleteDialogConfirm = new AlertDialog.Builder(scope.context());
    deleteDialogConfirm.setTitle(title);
    deleteDialogConfirm.setMessage(message);
    deleteDialogConfirm.setCancelable(true);

    deleteDialogConfirm.setPositiveButton(positivebtnText, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            flag = true;/*from   www  . j  a  v  a2  s .com*/
            getActivity().getSupportFragmentManager().popBackStack();
        }
    });

    deleteDialogConfirm.setNegativeButton(negativebtnText, null);

    deleteDialogConfirm.show();
}