List of usage examples for android.app AlertDialog.Builder setMessage
public void setMessage(CharSequence message)
From source file:com.getkickbak.plugin.NotificationPlugin.java
/** * Builds and shows a native Android alert with given Strings * //from ww w .j av a 2 s. c o m * @param message * The message the alert should display * @param title * The title of the alert * @param buttonLabel * The label of the button * @param callbackContext * The callback context */ public synchronized void alert(final String message, final String title, final String buttonLabel, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity()); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(true); dlg.setPositiveButton(buttonLabel, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); dlg.create(); dlg.show(); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.vishnuvalleru.travelweatheralertsystem.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_legalnotices: String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext()); AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(MainActivity.this); LicenseDialog.setTitle("Legal Notices"); LicenseDialog.setMessage(LicenseInfo); LicenseDialog.show();//from w w w . j a v a2 s . c om return true; } return super.onOptionsItemSelected(item); }
From source file:com.otaupdater.utils.KernelInfo.java
public void showUpdateDialog(final Context ctx) { AlertDialog.Builder alert = new AlertDialog.Builder(ctx); alert.setTitle(R.string.alert_update_title); alert.setMessage(ctx.getString(R.string.alert_update_kernel_to, kernelName, version)); alert.setPositiveButton(R.string.alert_download, new DialogInterface.OnClickListener() { @Override//from w w w.j av a 2 s. c o m public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); final File file = new File(Config.KERNEL_DL_PATH_FILE, getDownloadFileName()); if (file.exists()) { Log.v("OTA::Download", "Found old zip, checking md5"); InputStream is = null; try { is = new FileInputStream(file); MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] data = new byte[4096]; int nRead = -1; while ((nRead = is.read(data)) != -1) { digest.update(data, 0, nRead); } String oldMd5 = Utils.byteArrToStr(digest.digest()); Log.v("OTA::Download", "old zip md5: " + oldMd5); if (!md5.equalsIgnoreCase(oldMd5)) { file.delete(); } else { //TODO show flash dialog return; } } catch (Exception e) { e.printStackTrace(); file.delete(); } finally { if (is != null) { try { is.close(); } catch (Exception e) { } } } } final long dlID = fetchFile(ctx); AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.alert_downloading); builder.setMessage(ctx.getString(R.string.alert_downloading_changelog, changelog)); builder.setCancelable(true); builder.setPositiveButton(R.string.alert_hide, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); DownloadManager dm = (DownloadManager) ctx.getSystemService(Context.DOWNLOAD_SERVICE); dm.remove(dlID); } }); } }); alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.create().show(); }
From source file:com.otaupdater.utils.RomInfo.java
public void showUpdateDialog(final Context ctx) { AlertDialog.Builder alert = new AlertDialog.Builder(ctx); alert.setTitle(R.string.alert_update_title); alert.setMessage(ctx.getString(R.string.alert_update_rom_to, romName, version)); alert.setPositiveButton(R.string.alert_download, new DialogInterface.OnClickListener() { @Override/*from w w w . java 2 s . co m*/ public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); final File file = new File(Config.ROM_DL_PATH_FILE, getDownloadFileName()); if (file.exists()) { Log.v("OTA::Download", "Found old zip, checking md5"); InputStream is = null; try { is = new FileInputStream(file); MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] data = new byte[4096]; int nRead = -1; while ((nRead = is.read(data)) != -1) { digest.update(data, 0, nRead); } String oldMd5 = Utils.byteArrToStr(digest.digest()); Log.v("OTA::Download", "old zip md5: " + oldMd5); if (!md5.equalsIgnoreCase(oldMd5)) { file.delete(); } else { //TODO show flash dialog return; } } catch (Exception e) { e.printStackTrace(); file.delete(); } finally { if (is != null) { try { is.close(); } catch (Exception e) { } } } } final long dlID = fetchFile(ctx); AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.alert_downloading); builder.setMessage(ctx.getString(R.string.alert_downloading_changelog, changelog)); builder.setCancelable(true); builder.setPositiveButton(R.string.alert_hide, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); DownloadManager dm = (DownloadManager) ctx.getSystemService(Context.DOWNLOAD_SERVICE); dm.remove(dlID); } }); } }); alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.create().show(); }
From source file:com.fabernovel.alertevoirie.NewsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.report_detail_new_report_ok).setCancelable(false).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { NewsActivity.this.finish(); // Toast.makeText(this, R.string.report_detail_new_report_ok, Toast.LENGTH_SHORT).show(); NewsActivity.this.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); }/*from w w w . ja v a2s .com*/ }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.vishnuvalleru.travelweatheralertsystem.MainActivity.java
private void showAlert(String title, String message) { AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this); alert.setTitle(title);//from w ww . jav a 2 s . c o m alert.setCancelable(false); alert.setMessage(message); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.show(); }
From source file:com.nest5.businessClient.AccountsActivity.java
/** * Sets up the 'connect' screen content. *///from w w w. j av a 2 s . co m private void setConnectScreenContent() { List<String> accounts = getGoogleAccounts(); if (accounts.size() == 0) { // Show a dialog and invoke the "Add Account" activity if requested AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.needs_account); builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } }); builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); builder.setIcon(android.R.drawable.stat_sys_warning); builder.setTitle(R.string.attention); builder.show(); } else { final ListView listView = (ListView) findViewById(R.id.select_account); listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setItemChecked(mAccountSelectedPosition, true); final Button connectButton = (Button) findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Set "connecting" status SharedPreferences prefs = Util.getSharedPreferences(mContext); prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit(); // Get account name mAccountSelectedPosition = listView.getCheckedItemPosition(); TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition); // Register register((String) account.getText()); finish(); } }); } // internetConnectionStatus = (ImageView) findViewById(R.id.header_connection_status); SharedPreferences prefs = Util.getSharedPreferences(mContext); if (!isNetworkAvailable()) { internetConnectionStatus.setImageResource(R.drawable.error); prefs.edit().putInt(Util.INTERNET_CONNECTION, Util.INTERNET_DISCONNECTED).commit(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage( "No tienes una conexin a internet activa. Habiltala haciendo click en aceptar y seleccionando luego una red.") .setCancelable(false).setPositiveButton("Aceptar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); startActivityForResult(intent, 1); } }).setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }).show(); } else { prefs.edit().putInt(Util.INTERNET_CONNECTION, Util.INTERNET_CONNECTED).commit(); } }
From source file:es.uniovi.imovil.fcrtrainer.HexadecimalExerciseFragment.java
/** * Shows a dialog with the game stats when the game is over * /* w w w. ja v a 2s . c o m*/ * @param remainingTime */ public void showEndGameDialog(int remainingTime) { AlertDialog.Builder abuilder = new AlertDialog.Builder(getActivity()); abuilder.setTitle(getString(R.string.game_over)); if (remainingTime > 0) abuilder.setMessage(String.format(getString(R.string.gameisoverexp), remainingTime, pointsCounter)); else abuilder.setMessage(String.format(getString(R.string.lost_time_over), pointsCounter)); abuilder.create().show(); }
From source file:com.sakisds.icymonitor.fragments.graph.GraphContainerFragment.java
/** * Shows an error dialog/*from w w w . j a v a2s .co m*/ * * @param error */ protected void showErrorDialog(int error) { AlertDialog.Builder dlgAlert = new AlertDialog.Builder(getActivity()); dlgAlert.setMessage(getResources().getString(error)); dlgAlert.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dlgAlert.setCancelable(true); dlgAlert.create().show(); }
From source file:com.googlecode.android_scripting.ZipExtractorTask.java
private Replace showDialog(final String name) { final FutureResult<Replace> mResult = new FutureResult<Replace>(); MainThread.run(mContext, new Runnable() { @Override// w w w .java 2s .c o m public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setTitle(String.format("Script \"%s\" already exist.", name)); builder.setMessage(String.format("Do you want to replace script \"%s\" ?", name)); DialogInterface.OnClickListener buttonListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Replace result = Replace.SKIPALL; switch (which) { case DialogInterface.BUTTON_POSITIVE: result = Replace.YES; break; case DialogInterface.BUTTON_NEGATIVE: result = Replace.NO; break; case DialogInterface.BUTTON_NEUTRAL: result = Replace.YESTOALL; break; } mResult.set(result); dialog.dismiss(); } }; builder.setNegativeButton("Skip", buttonListener); builder.setPositiveButton("Replace", buttonListener); builder.setNeutralButton("Replace All", buttonListener); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mResult.set(Replace.SKIPALL); dialog.dismiss(); } }); builder.show(); } }); try { return mResult.get(); } catch (InterruptedException e) { Log.e(e); } return null; }