Example usage for android.app AlertDialog setMessage

List of usage examples for android.app AlertDialog setMessage

Introduction

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

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:cm.aptoide.pt.ManageRepo.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.repolist);/*from   w  ww  .java2 s.  c o  m*/

    db = new DbHandler(this);

    Intent i = getIntent();
    if (i.hasExtra("empty")) {
        final String uri = i.getStringExtra("uri");
        AlertDialog alrt = new AlertDialog.Builder(this).create();
        alrt.setTitle(getString(R.string.title_repo_alrt));
        alrt.setIcon(android.R.drawable.ic_dialog_alert);
        alrt.setMessage(getString(R.string.myrepo_alrt) + uri);
        alrt.setButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                db.addServer(uri);
                change = true;
                redraw();
                return;
            }
        });
        alrt.setButton2("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }
        });
        alrt.show();
    } else if (i.hasExtra("uri")) {
        String uri = i.getStringExtra("uri");
        Vector<String> new_serv_lst = getRemoteServLst(uri);
        for (final String srv : new_serv_lst) {
            AlertDialog alrt = new AlertDialog.Builder(this).create();
            alrt.setTitle(getString(R.string.title_repo_alrt));
            alrt.setIcon(android.R.drawable.ic_dialog_alert);
            alrt.setMessage(getString(R.string.newrepo_alrt) + srv);
            alrt.setButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    db.addServer(srv);
                    change = true;
                    redraw();
                    return;
                }
            });
            alrt.setButton2("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    return;
                }
            });
            alrt.show();
        }
    } else if (i.hasExtra("newrepo")) {
        final String repo = i.getStringExtra("newrepo");
        AlertDialog alrt = new AlertDialog.Builder(this).create();
        alrt.setTitle(getString(R.string.title_repo_alrt));
        alrt.setIcon(android.R.drawable.ic_dialog_alert);
        alrt.setMessage(getString(R.string.newrepo_alrt) + repo);
        alrt.setButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                db.addServer(repo);
                change = true;
                redraw();
                return;
            }
        });
        alrt.setButton2("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //exit
            }
        });
        alrt.show();
    }
}

From source file:com.xperia64.timidityae.FileBrowserFragment.java

public void getDir(String dirPath) {
    currPath = dirPath;/*from www .j av a  2  s. co m*/
    fname = new ArrayList<String>();
    path = new ArrayList<String>();
    if (currPath != null) {
        File f = new File(currPath);
        if (f.exists()) {
            File[] files = f.listFiles();
            if (files != null && files.length > 0) {

                Arrays.sort(files, new FileComparator());

                // System.out.println(currPath);
                if (!currPath.matches("[/]+")) {
                    fname.add("../");
                    path.add(f.getParent() + "/");
                    mCallback.needFileBackCallback(true);
                } else {
                    mCallback.needFileBackCallback(false);
                }
                for (int i = 0; i < files.length; i++) {
                    File file = files[i];
                    if ((!file.getName().startsWith(".") && !Globals.showHiddenFiles)
                            || Globals.showHiddenFiles) {
                        if (file.isFile()) {
                            int dotPosition = file.getName().lastIndexOf(".");
                            String extension = "";
                            if (dotPosition != -1) {
                                extension = (file.getName().substring(dotPosition)).toLowerCase(Locale.US);
                                if (extension != null) {

                                    if ((Globals.showVideos ? Globals.musicVideoFiles : Globals.musicFiles)
                                            .contains("*" + extension + "*")) {

                                        path.add(file.getAbsolutePath());
                                        fname.add(file.getName());
                                    }
                                } else if (file.getName().endsWith("/")) {
                                    path.add(file.getAbsolutePath() + "/");
                                    fname.add(file.getName() + "/");
                                }
                            }
                        } else {
                            path.add(file.getAbsolutePath() + "/");
                            fname.add(file.getName() + "/");
                        }
                    }
                }
            } else {
                if (!currPath.matches("[/]+")) {
                    fname.add("../");
                    path.add(f.getParent() + "/");

                }
            }
            ArrayAdapter<String> fileList = new ArrayAdapter<String>(getActivity(), R.layout.row, fname);
            getListView().setFastScrollEnabled(true);
            getListView().setOnItemLongClickListener(new OnItemLongClickListener() {

                @Override
                public boolean onItemLongClick(AdapterView<?> l, View v, final int position, long id) {
                    localfinished = false;
                    if (new File(path.get(position)).isFile() && Globals.isMidi(path.get(position))) {

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

                        alert.setTitle("Convert to WAV File");
                        alert.setMessage(
                                "Exports the MIDI/MOD file to WAV.\nNative Midi must be disabled in settings.\nWarning: WAV files are large.");
                        InputFilter filter = new InputFilter() {
                            public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                                    int dstart, int dend) {
                                for (int i = start; i < end; i++) {
                                    String IC = "*/*\n*\r*\t*\0*\f*`*?***\\*<*>*|*\"*:*";
                                    if (IC.contains("*" + source.charAt(i) + "*")) {
                                        return "";
                                    }
                                }
                                return null;
                            }
                        };
                        // Set an EditText view to get user input 
                        final EditText input = new EditText(getActivity());
                        input.setFilters(new InputFilter[] { filter });
                        alert.setView(input);

                        alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                String value = input.getText().toString();
                                if (!value.toLowerCase(Locale.US).endsWith(".wav"))
                                    value += ".wav";
                                String parent = path.get(position).substring(0,
                                        path.get(position).lastIndexOf('/') + 1);
                                boolean aWrite = true;
                                boolean alreadyExists = new File(parent + value).exists();
                                String needRename = null;
                                String probablyTheRoot = "";
                                String probablyTheDirectory = "";
                                try {
                                    new FileOutputStream(parent + value, true).close();
                                } catch (FileNotFoundException e) {
                                    aWrite = false;
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                                if (!alreadyExists && aWrite)
                                    new File(parent + value).delete();
                                if (aWrite && new File(parent).canWrite()) {
                                    value = parent + value;
                                } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
                                        && Globals.theFold != null) {
                                    // Write the file to getExternalFilesDir, then move it with the Uri
                                    // We need to tell JNIHandler that movement is needed.

                                    String[] tmp = Globals.getDocFilePaths(getActivity(), parent);
                                    probablyTheDirectory = tmp[0];
                                    probablyTheRoot = tmp[1];
                                    if (probablyTheDirectory.length() > 1) {
                                        needRename = parent.substring(
                                                parent.indexOf(probablyTheRoot) + probablyTheRoot.length())
                                                + value;
                                        value = probablyTheDirectory + '/' + value;
                                    } else {
                                        value = Environment.getExternalStorageDirectory().getAbsolutePath()
                                                + '/' + value;
                                    }
                                } else {
                                    value = Environment.getExternalStorageDirectory().getAbsolutePath() + '/'
                                            + value;
                                }
                                final boolean canWrite = aWrite;
                                final String finalval = value;
                                final String needToRename = needRename;
                                final String probRoot = probablyTheRoot;
                                if (new File(finalval).exists()
                                        || (new File(probRoot + needRename).exists() && needToRename != null)) {
                                    AlertDialog dialog2 = new AlertDialog.Builder(getActivity()).create();
                                    dialog2.setTitle("Warning");
                                    dialog2.setMessage("Overwrite WAV file?");
                                    dialog2.setCancelable(false);
                                    dialog2.setButton(DialogInterface.BUTTON_POSITIVE,
                                            getResources().getString(android.R.string.yes),
                                            new DialogInterface.OnClickListener() {
                                                public void onClick(DialogInterface dialog, int buttonId) {
                                                    if (!canWrite
                                                            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                                                        if (needToRename != null) {
                                                            Globals.tryToDeleteFile(getActivity(),
                                                                    probRoot + needToRename);
                                                            Globals.tryToDeleteFile(getActivity(), finalval);
                                                        } else {
                                                            Globals.tryToDeleteFile(getActivity(), finalval);
                                                        }
                                                    } else {
                                                        new File(finalval).delete();
                                                    }

                                                    saveWavPart2(position, finalval, needToRename);

                                                }

                                            });
                                    dialog2.setButton(DialogInterface.BUTTON_NEGATIVE,
                                            getResources().getString(android.R.string.no),
                                            new DialogInterface.OnClickListener() {
                                                public void onClick(DialogInterface dialog, int buttonId) {

                                                }
                                            });
                                    dialog2.show();
                                } else {
                                    saveWavPart2(position, finalval, needToRename);
                                }

                            }
                        });

                        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                // Canceled.
                            }
                        });

                        alert.show();

                        return true;
                    } else {

                    }
                    return false;
                }

            });
            setListAdapter(fileList);
        }
    }
}

From source file:com.example.SimpleTestClient.Activities.TestMainActivity.java

private void showInformationBox() {
    if (this.showingQuestion != null) {
        String msg = "";
        String title = "";
        if (this.showingQuestion.getQuestionModel().Type == QuestionBase.QuestionType.SingleChoice) {
            msg = getResources().getString(R.string.info_question_singleChoice);
            title = "? ?  ";
        }/*from   ww  w  .  j  a  va 2  s. c  om*/
        if (this.showingQuestion.getQuestionModel().Type == QuestionBase.QuestionType.MultiChoice) {
            msg = getResources().getString(R.string.info_question_multiChoice);
            title = "? ? ? ";
        }
        if (this.showingQuestion.getQuestionModel().Type == QuestionBase.QuestionType.TextQuestion) {
            msg = getResources().getString(R.string.info_question_textChoice);
            title = "? ?     ?";
        }

        AlertDialog ad = new AlertDialog.Builder(this).create();
        ad.setIcon(R.drawable.ic_action_about);
        ad.setTitle(title);
        //  ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage(msg);
        ad.setButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        ad.show();

    }
}

From source file:com.androidquery.service.MarketService.java

protected void showUpdateDialog(JSONObject jo) {

    if (jo == null || version != null)
        return;// www  .ja v  a 2 s  . c  o  m

    if (!isActive())
        return;

    JSONObject dia = jo.optJSONObject("dialog");

    String update = dia.optString("update", "Update");
    String skip = dia.optString("skip", "Skip");
    String rate = dia.optString("rate", "Rate");
    //String message = dia.optString("body", "");
    String body = dia.optString("wbody", "");
    String title = dia.optString("title", "Update Available");

    AQUtility.debug("wbody", body);

    version = jo.optString("version", null);

    Drawable icon = getAppIcon();

    Context context = act;

    final AlertDialog dialog = new AlertDialog.Builder(context).setIcon(icon).setTitle(title)
            .setPositiveButton(rate, handler).setNeutralButton(skip, handler).setNegativeButton(update, handler)
            .create();

    dialog.setMessage(Html.fromHtml(patchBody(body), null, handler));

    aq.show(dialog);

    return;

}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

public void pingpicked(JSONObject json) {

    try {//from  w w w.  j  av  a  2 s. c o  m

        int driverpicked = json.getInt("picked");
        int drivercancelled = json.getInt("dcancel");
        int starttime = json.getInt("datetime");

        // /////////////////////////////// DRIVER CANCEL ////////
        if (drivercancelled == 1) {

            // //// DRIVER CANCEL LATE /////

            if (starttime + 300 <= Query.getServerTime()) {
                handlerboolean = false;
                handler.removeCallbacks(r);

                AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
                dcancelbuilder
                        .setMessage("Job has been cancelled.\nWould you like to report a late cancellation?.");

                // //// DRIVER CANCEL LATE - NO REPORT LATE/////
                button_cancelJob_noquery(dcancelbuilder);
                // //// DRIVER CANCEL LATE - REPORT LATE /////
                button_drivercancel_reportlate(dcancelbuilder);

                dcancelbuilder.show();

            } else {
                // /////////////////////////////// DRIVER CANCEL NO ALERTS -
                // WITHIN TIME LIMIT///////////////
                handlerboolean = false;
                handler.removeCallbacks(r);

                alertdialog_drivercancelintime();

            }
        }
        if (driverpicked == 1) {
            // /////////////////////////////// CONFIRM PICK UP
            // ///////////////////////////////////////////

            handlerboolean = false;
            handler.removeCallbacks(r);
            AlertDialog.Builder alert = new AlertDialog.Builder(OnrouteScreen.this);
            final Drawable thumbsup = getResources().getDrawable(R.drawable.thumbsup);
            final Drawable thumbsupwhite = getResources().getDrawable(R.drawable.thumbsupwhite);
            final Drawable thumbsdown = getResources().getDrawable(R.drawable.thumbsdown);
            final Drawable thumbsdownwhite = getResources().getDrawable(R.drawable.thumbsdownwhite);
            LinearLayout layout = new LinearLayout(OnrouteScreen.this);
            layout.setOrientation(1);
            layout.setGravity(17);

            TextView tx1 = new TextView(OnrouteScreen.this);
            tx1.setText("Driver says you have been picked up");
            tx1.setGravity(17);
            tx1.setTextSize(20);
            tx1.setTextColor(Color.WHITE);
            tx1.setPadding(10, 10, 10, 10);

            TextView tx2 = new TextView(OnrouteScreen.this);
            tx2.setText("Please rate your driver");
            tx2.setGravity(17);
            tx2.setTextSize(16);

            LinearLayout imglayout = new LinearLayout(OnrouteScreen.this);
            imglayout.setOrientation(0);
            imglayout.setGravity(17);

            final ImageView ivup = new ImageView(OnrouteScreen.this);
            ivup.setImageDrawable(thumbsupwhite);
            ivup.setClickable(true);
            ivup.setPadding(0, 5, 30, 5);
            final ImageView ivdown = new ImageView(OnrouteScreen.this);
            ivdown.setImageDrawable(thumbsdownwhite);
            ivdown.setClickable(true);
            ivup.setPadding(30, 5, 0, 5);
            imglayout.addView(ivup);
            imglayout.addView(ivdown);

            layout.addView(tx1);
            layout.addView(tx2);

            layout.addView(imglayout);
            // /////////////////////////////// CONFIRM PICK UP - RATINGS
            // ///////////////////////////////////////////

            ivup.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if (thumbsupboolean == false) {
                        thumbsupboolean = true;
                        thumbsdownboolean = false;
                        ivup.setImageDrawable(thumbsup);
                        ivdown.setImageDrawable(thumbsdownwhite);
                        rating = 1;
                    } else {
                        thumbsupboolean = false;
                        ivup.setImageDrawable(thumbsupwhite);
                        rating = 0;
                    }

                }
            });

            ivdown.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if (thumbsdownboolean == false) {
                        thumbsdownboolean = true;
                        thumbsupboolean = false;
                        ivdown.setImageDrawable(thumbsdown);
                        ivup.setImageDrawable(thumbsupwhite);

                        AlertDialog alert = new AlertDialog.Builder(OnrouteScreen.this).create();

                        alert.setMessage("Please pick one");
                        alert.setButton("No show", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                rating = -1;
                            }
                        });
                        alert.setButton2("Driver late", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                rating = -2;
                            }
                        });
                        alert.setButton3("Poor service", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                rating = -3;
                            }
                        });
                        alert.show();

                    } else {
                        thumbsupboolean = false;
                        ivdown.setImageDrawable(thumbsdownwhite);
                        rating = 0;
                    }

                }
            });

            button_completed_finish(alert);

            alert.setView(layout);
            alert.create();
            alert.show();
        } else {
        }

    } catch (JSONException e) {
    }
}

From source file:com.teamproject.shoutbox.MainActivity.java

public void showAlertDialog() {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();

    // Setting Dialog Title
    alertDialog.setTitle("ShoutBox");
    // String s= (Html.fromHtml("<a href=\"http://www.google.com\">Check this link out</a>")).toString();
    // Setting Dialog Message
    alertDialog.setMessage(
            "No abusive/offensive words please. You'll unnecessarily increase your chances of getting banned!");
    // Setting Icon to Dialog
    alertDialog.setIcon(R.drawable.icon);

    // Setting OK Button
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            //Toast.makeText(getApplicationContext(), "You clicked on OK", Toast.LENGTH_SHORT).show();
        }//from   ww w .ja  v a2  s  .  com
    });

    // Showing Alert Message
    alertDialog.show();
}

From source file:org.loon.framework.android.game.LGameActivity.java

/**
 * ??Alter/*from   ww w .j av  a  2s .  co  m*/
 * 
 * @param message
 */
public void showAndroidAlert(final String title, final String message) {
    Runnable showAlert = new Runnable() {
        public void run() {
            final AlertDialog alert = new AlertDialog.Builder(LGameActivity.this).create();
            alert.setTitle(title);
            alert.setMessage(message);
            alert.setButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    alert.dismiss();
                }
            });
            alert.show();
        }
    };
    runOnUiThread(showAlert);
}

From source file:com.glm.trainer.NewMainActivity.java

@Override
public void onBackPressed() {
    AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle(this.getString(R.string.titleendapp));
    alertDialog.setMessage(this.getString(R.string.messageendapp));
    alertDialog.setButton(this.getString(R.string.yes), new android.content.DialogInterface.OnClickListener() {

        @Override//from  w  ww  .j a v a2s . c  o m
        public void onClick(DialogInterface arg0, int arg1) {
            if (mConnection != null && mConnection.mIService != null) {
                try {
                    mConnection.mIService.stopGPSFix();
                    mConnection.mIService.shutDown();
                    mConnection.destroy();
                } catch (RemoteException e) {
                    // TODO Auto-generated catch block
                    //Log.e(this.getClass().getCanonicalName(),e.getMessage());
                }
            }
            finish();
        }
    });

    alertDialog.setButton2(this.getString(R.string.no), new android.content.DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {

        }

    });
    alertDialog.show();
}

From source file:org.rapidandroid.activity.FormCreator.java

@Override
public void onBackPressed() {
    AlertDialog dialog = new AlertDialog.Builder(this).create();

    dialog.setMessage("Save Changes First?");
    dialog.setButton(DialogInterface.BUTTON_POSITIVE, "Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface d, int which) {
            doSave();//from  w  ww.j  ava2 s  .co m
            finish();
        }
    });

    dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface d, int which) {
            finish();
        }
    });

    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface d, int which) {
        }
    });
    dialog.show();
}

From source file:com.glm.trainer.NewMainActivity.java

/**
 * Visualizza una alert per il GPS non abilitato
 *
 * @author Gianluca Masci aka (GLM)//from  w w w  . ja va  2 s  .  com
 * */
public void ShowAlertNoGPS() {
    try {
        AlertDialog alertDialog;
        alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(this.getString(R.string.titlegps));
        alertDialog.setMessage(this.getString(R.string.messagegpsnoenabled));
        alertDialog.setButton(this.getString(R.string.yes),
                new android.content.DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(myIntent);
                    }
                });

        alertDialog.setButton2(this.getString(R.string.no),
                new android.content.DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {

                    }

                });
        alertDialog.show();
    } catch (Exception e) {
        Toast.makeText(this, "ERROR DIALOG:" + e.getMessage(), Toast.LENGTH_SHORT).show();
        Log.e("MEEERR: ", e.getMessage());
    }
}