List of usage examples for android.app AlertDialog setMessage
public void setMessage(CharSequence message)
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
private void switchFlash() { boolean hasFlash = getApplicationContext().getPackageManager() .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); if (!hasFlash) { // device doesn't support flash // Show alert message and close the application AlertDialog alert = new AlertDialog.Builder(this).create(); alert.setTitle("Error"); alert.setMessage("Sorry, your device doesn't support flash light!"); alert.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { }//from w ww . j a v a 2s . c o m }); alert.show(); return; } if (isFlashOn) { // turn off flash turnOffFlash(); } else { // turn on flash turnOnFlash(); } }
From source file:fr.android.scaron.diaspdroid.vues.fragment.ParamsFragment.java
@UiThread public void showResultLogin(boolean loginOK) { String methodName = ".showResultLogin : "; LOG.d(methodName + "Entre"); if (loginOK) { final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( DiasporaConfig.APPLICATION_CONTEXT); final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { @Override/* w w w . j a v a 2s. c o m*/ public void onClick(final DialogInterface dialog, final int which) { String methodName = ".showResultLogin/loginOK/onClick : "; LOG.d(methodName + "Entre"); DiasporaConfig.ParamsOK = true; DiasporaConfig.DB.putBoolean("configOK", true); LOG.d(methodName + "Params to true"); LOG.d(methodName + "main activity type is " + activity.getClass().getName()); if (activity instanceof MainActivity_) { LOG.d(methodName + "call set defaultView on MainActivity_"); ((MainActivity_) activity).setDefaultView(); } else if (activity instanceof MainActivity) { LOG.d(methodName + "call set defaultView on MainActivity"); ((MainActivity) activity).setDefaultView(); } alertDialog.dismiss(); } }); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setTitle("Connexion russie"); alertDialog.setMessage("Vos paramtres sont correctes.\nBon surf sur Diaspora !"); alertDialog.show(); LOG.d(methodName + "Sortie"); return; } final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(DiasporaConfig.APPLICATION_CONTEXT); final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { String methodName = ".showResultLogin/loginKO/onClick : "; LOG.d(methodName + "Entre"); DiasporaConfig.ParamsOK = false; DiasporaConfig.DB.putBoolean("configOK", false); LOG.d(methodName + "Params to false"); alertDialog.dismiss(); } }); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setTitle("PB Connexion"); alertDialog.setMessage("La connexion a Diaspora a choue"); alertDialog.show(); LOG.d(methodName + "Sortie en erreur"); }
From source file:com.tweetlanes.android.view.BaseLaneActivity.java
public void shareSelected(TwitterStatus status) { if (status != null) { final String statusUrl = status.getTwitterComStatusUrl(); final String statusText = status.mStatus; final ArrayList<String> urls = Util.getUrlsInString(status.mStatus); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.alert_share_title)); alertDialog.setMessage(getString(R.string.alert_share_message)); alertDialog.setIcon(AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Dark ? R.drawable.ic_action_share_dark : R.drawable.ic_action_share_light); // TODO: The order these buttons are set looks wrong, but appears correctly. Have to ensure this is consistent on other devices. alertDialog.setButton2(getString(R.string.share_tweet_link), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(statusUrl);/*from w w w .j a va2 s .c o m*/ } }); if (urls != null && urls.size() > 0) { alertDialog.setButton3(getString(R.string.share_tweet), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(statusText); } }); alertDialog.setButton(getString(urls.size() == 1 ? R.string.share_link : R.string.share_first_link), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(urls.get(0)); } }); } else { alertDialog.setButton(getString(R.string.share_tweet), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(statusText); } }); } alertDialog.show(); } }
From source file:dev.memento.MementoBrowser.java
@Override protected void onPrepareDialog(int id, Dialog dialog) { super.onPrepareDialog(id, dialog); switch (id) { case DIALOG_DATE: // To fix a bug described here: http://www.zunisoft.com/?p=1140 DatePickerDialog dlg = (DatePickerDialog) dialog; DateFormat longDateFormat = new SimpleDateFormat("EEEE, MMMM d, yyyy"); dlg.setTitle(longDateFormat.format(mDateChosen.getDate())); dlg.updateDate(mDateChosen.getYear(), mDateChosen.getMonth() - 1, mDateChosen.getDay()); break;// w w w.j a v a2s. c o m case DIALOG_ERROR: AlertDialog ad = (AlertDialog) dialog; ad.setMessage(mErrorMessage); mErrorMessage = null; break; } }
From source file:com.tweetlanes.android.core.view.BaseLaneActivity.java
public void shareSelected(TwitterStatus status) { if (status != null) { App application = (App) getApplication(); AccountDescriptor currentAccount = application.getCurrentAccount(); String url;//from w w w. jav a 2 s . c om String shareText; if (currentAccount.getSocialNetType() == SocialNetConstant.Type.Twitter) { url = status.getTwitterComStatusUrl(); shareText = getString(R.string.share_tweet_link); } else { url = status.getAdnStatusUrl(); shareText = getString(R.string.share_tweet_post); } final String statusUrl = url; final String statusText = status.mStatus; final ArrayList<String> urls = Util.getUrlsInString(status.mStatus); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.alert_share_title)); alertDialog.setMessage(getString(R.string.alert_share_message)); alertDialog.setIcon(AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Dark || AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Light_DarkAction ? R.drawable.ic_action_share_dark : R.drawable.ic_action_share_light); // TODO: The order these buttons are set looks wrong, but appears // correctly. Have to ensure this is consistent on other devices. alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.share_tweet), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(statusText); } }); alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, shareText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(statusUrl); } }); if (urls != null && urls.size() > 0) { alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(urls.size() == 1 ? R.string.share_link : R.string.share_first_link), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(urls.get(0)); } }); } alertDialog.show(); } }
From source file:com.shafiq.mytwittle.view.BaseLaneActivity.java
public void shareSelected(TwitterStatus status) { if (status != null) { final String statusUrl = status.getTwitterComStatusUrl(); final String statusText = status.mStatus; final ArrayList<String> urls = Util.getUrlsInString(status.mStatus); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.alert_share_title)); alertDialog.setMessage(getString(R.string.alert_share_message)); alertDialog.setIcon(AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Dark ? R.drawable.ic_action_share_dark : R.drawable.ic_action_share_light); // TODO: The order these buttons are set looks wrong, but appears // correctly. Have to ensure this is consistent on other devices. alertDialog.setButton2(getString(R.string.share_tweet_link), new DialogInterface.OnClickListener() { @Override/*from w ww.j a va 2s . c o m*/ public void onClick(DialogInterface dialog, int which) { shareText(statusUrl); } }); if (urls != null && urls.size() > 0) { alertDialog.setButton3(getString(R.string.share_tweet), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { shareText(statusText); } }); alertDialog.setButton(getString(urls.size() == 1 ? R.string.share_link : R.string.share_first_link), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { shareText(urls.get(0)); } }); } else { alertDialog.setButton(getString(R.string.share_tweet), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { shareText(statusText); } }); } alertDialog.show(); } }
From source file:devza.app.android.droidnetkey.FirewallAction.java
@Override protected void onPostExecute(Integer result) { /*INVALID_CREDENTIALS = -1; TIMED_OUT = -2;/* w w w.jav a 2 s . c o m*/ GENERAL_ERROR = -3;*/ if (!refresh) { d.dismiss(); if (result < 0) { AlertDialog error = new AlertDialog.Builder(this.context).create(); error.setTitle("Error"); error.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int id) { d.cancel(); } }); String msg; switch (result) { case INVALID_CREDENTIALS: msg = "Invalid Username or Password"; break; case TIMED_OUT: msg = "Connection Timed Out. Is your device connected to the internet?"; break; case UNKNOWN_HOST: msg = "Could not connect. Is your device connected to the internet?"; break; case GENERAL_ERROR: msg = "General Error.\n Please send some more information about this error to 15629368@sun.ac.za"; break; default: msg = "General Error.\n Please send some more information about this error to 15629368@sun.ac.za"; break; } error.setMessage(msg); error.show(); } else { if (result == CONNECTED) { Intent usage = new Intent(this.context, UsageActivity.class); this.context.startActivity(usage); this.s.showNotification(true); this.s.startTimer(); } else { Intent main = new Intent(this.context, MainActivity.class); this.context.startActivity(main); this.s.showNotification(false); } } } }
From source file:com.xperia64.rompatcher.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); staticThis = MainActivity.this; setContentView(R.layout.main);/*from w w w. j a v a 2s . c o m*/ // Load native libraries try { System.loadLibrary("apsn64patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab apspatcher!"); } try { System.loadLibrary("ipspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ipspatcher!"); } try { System.loadLibrary("ipspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ipspatcher!"); } try { System.loadLibrary("upspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab upspatcher!"); } try { System.loadLibrary("xdelta3patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab xdelta3patcher!"); } try { System.loadLibrary("bpspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bpspatcher!"); } try { System.loadLibrary("bzip2"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bzip2!"); } try { System.loadLibrary("bsdiffpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bsdiffpatcher!"); } try { System.loadLibrary("ppfpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ppfpatcher!"); } try { System.loadLibrary("ips32patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("glib-2.0"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab glib-2.0!"); } try { System.loadLibrary("gmodule-2.0"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab gmodule-2.0!"); } try { System.loadLibrary("edsio"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab edsio!"); } try { System.loadLibrary("xdelta1patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("ips32patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("ecmpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ecmpatcher!"); } try { System.loadLibrary("dpspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab dpspatcher!"); } try { System.loadLibrary("dldipatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab dldipatcher!"); } try { System.loadLibrary("xpcpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab xpcpatcher!"); } try { System.loadLibrary("asarpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab asarpatcher!"); } try { System.loadLibrary("asmpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab asmpatcher!"); } c = (CheckBox) findViewById(R.id.backupCheckbox); d = (CheckBox) findViewById(R.id.altNameCheckbox); r = (CheckBox) findViewById(R.id.ignoreCRC); e = (CheckBox) findViewById(R.id.fileExtCheckbox); ed = (EditText) findViewById(R.id.txtOutFile); final Button romButton = (Button) findViewById(R.id.romButton); romButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Globals.mode = true; Intent intent = new Intent(staticThis, FileBrowserActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(intent, 1); } }); final Button patchButton = (Button) findViewById(R.id.patchButton); patchButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Globals.mode = false; Intent intent = new Intent(staticThis, FileBrowserActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(intent, 1); } }); final ImageButton bkHelp = (ImageButton) findViewById(R.id.backupHelp); bkHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.bkup_rom)); dialog.setMessage(getResources().getString(R.string.bkup_rom_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); final ImageButton altNameHelp = (ImageButton) findViewById(R.id.outfileHelp); altNameHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.rename1)); dialog.setMessage(getResources().getString(R.string.rename_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); final ImageButton chkHelp = (ImageButton) findViewById(R.id.ignoreHelp); chkHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.ignoreChks)); dialog.setMessage(getResources().getString(R.string.ignoreChks_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); 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; } }; ed.setFilters(new InputFilter[] { filter }); c.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { d.setEnabled(true); if (d.isChecked()) { ed.setEnabled(true); e.setEnabled(true); } } else { d.setEnabled(false); ed.setEnabled(false); e.setEnabled(false); } } }); d.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { ed.setEnabled(true); e.setEnabled(true); } else { e.setEnabled(false); ed.setEnabled(false); } } }); final Button applyButton = (Button) findViewById(R.id.applyPatch); applyButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Warn about patching archives. if (Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".7z") || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".zip") || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".rar")) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.warning)); dialog.setMessage(getResources().getString(R.string.zip_warning_desc)); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { patchCheck(); } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { Toast t = Toast.makeText(staticThis, getResources().getString(R.string.nopatch), Toast.LENGTH_SHORT); t.show(); } }); dialog.show(); } else { patchCheck(); } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // Uggh. requestPermissions(); } }
From source file:de.blinkt.openvpn.ActivityDashboard.java
public void handlerMessageBox(int id, Handler handler, String title, String message, String yes, String no, String cancel) {/*from ww w . j ava 2s .com*/ AlertDialog box = new AlertDialog.Builder(this).create(); HandlerDialogClickListener listener = new HandlerDialogClickListener(handler, id); if (yes != null) box.setButton(AlertDialog.BUTTON_POSITIVE, yes, listener); if (no != null) box.setButton(AlertDialog.BUTTON_NEUTRAL, no, listener); if (cancel != null) box.setButton(AlertDialog.BUTTON_NEGATIVE, cancel, listener); box.setTitle(title); box.setMessage(message); box.show(); }