List of usage examples for android.app AlertDialog.Builder setMessage
public void setMessage(CharSequence message)
From source file:jp.watnow.plugins.dialog.Notification.java
/** * Builds and shows a native Android alert with given Strings * @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 */// w ww. j a v a 2s . c o m 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 = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); 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)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.cricketkorner.cricket.VitamioListActivity.java
private void ListFunction() { listView = (ListView) findViewById(R.id.listView); //copying array for (int i = 0; i < Singleton.getInstance().getChannelList().size(); i++) { title.add(Singleton.getInstance().getChannelList().get(i).getChannelName()); desc.add("Long Press This Channel To Report, Id: " + Singleton.getInstance().getChannelList().get(i).getChannelId()); thumb.add(R.drawable.ic_launcher); }//from w w w . ja va 2 s . com listView.setAdapter(new VersionAdapter(VitamioListActivity.this)); listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { AlertDialog.Builder alert = new AlertDialog.Builder(VitamioListActivity.this); alert.setTitle("Report Broken Link"); alert.setMessage("Message: (Channel not working?)"); // Set an EditText view to get user input final EditText input = new EditText(VitamioListActivity.this); alert.setView(input); alert.setPositiveButton("Submit", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); if (isNetworkAvailable()) { new ReportFeedback().execute("http://yoururl.com/LiveStreaming/reportFeedback.php", value, Singleton.getInstance().getChannelList().get(position).getChannelId()); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); return false; } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { int pos = arg2; LayoutInflater layoutInflator = getLayoutInflater(); View layout = layoutInflator.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView iv = (ImageView) layout.findViewById(R.id.toast_iv); TextView tv = (TextView) layout.findViewById(R.id.toast_tv); iv.setBackgroundResource(thumb.get(pos)); tv.setText(title.get(pos)); Intent intent = new Intent(VitamioListActivity.this, VideoViewDemo.class); intent.putExtra("path", Singleton.getInstance().getChannelList().get(pos).getChannelPath()); startAppAd.onBackPressed(); startActivity(intent); } }); }
From source file:com.dtr.zxing.activity.CaptureActivity.java
private void displayFrameworkBugMessageAndExit() { // camera error AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name)); builder.setMessage("???"); builder.setPositiveButton("", new DialogInterface.OnClickListener() { @Override/* w w w . ja v a 2 s. 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:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java
/** * Show dialog error//from w w w.ja va2 s .com * @param errStr */ public void showDialogError(String errStr) { AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setIcon(R.drawable.icon); adb.setTitle(R.string.str_ErrPlay_Title); adb.setMessage(errStr); adb.setPositiveButton(R.string.str_OK, new OnClickListener() { public void onClick(DialogInterface a0, int a1) { finish(); } }); adb.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { dialog.dismiss(); finish(); return true; } return false; } }); AlertDialog ad = adb.create(); ad.show(); }
From source file:jieehd.villain.updater.VillainUpdater.java
private boolean haveNetworkConnection() { boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) haveConnectedWifi = true; if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) haveConnectedMobile = true; }// w w w . java 2 s . c om if (haveConnectedWifi == false && haveConnectedMobile == false) { Log.d("Network State", "false"); AlertDialog.Builder alert = new AlertDialog.Builder(VillainUpdater.this); alert.setTitle("No Data Connection!"); alert.setMessage( "You have no data connection, click ok to turn on WiFi or Mobile Data in order to check for OTA updates."); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // TODO Auto-generated method stub final Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_LAUNCHER); final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.wifi.WifiSettings"); intent.setComponent(cn); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub return; } }); alert.show(); } else { download(); } return haveConnectedWifi || haveConnectedMobile; }
From source file:net.gerosyab.dailylog.activity.MainActivity.java
private void deleteCategory(final long id) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setMessage(getResources().getString(R.string.dialog_message_confirm_delete_category) + " [" + categories.get((int) id).getName() + "]") .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override//from ww w . j a v a 2 s. c o m public void onClick(DialogInterface dialog, int which) { categories.get((int) id).deleteCategory(realm); adapter.notifyDataSetChanged(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).show(); }
From source file:fr.pasteque.client.Configure.java
/** * Display an AlertDialog/*from w w w.j a v a 2s .c o m*/ * Based on Error.showError() but Configuration is not a TrackedActivity * * @param message to display */ private void showError(String message) { AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle(R.string.error_title); b.setMessage(message); b.setIcon(android.R.drawable.ic_dialog_alert); b.setCancelable(true); b.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Configure.this.invalidateError(); } }); b.show(); }
From source file:net.evecom.android.log.DailyLogAddActivity.java
/** * //from ww w. j av a2 s . co m */ private String submit() { /** */ if (btEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (sswgButton.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (rzlxButton.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (gzsjButton.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (rznrEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (years > calendar.get(Calendar.YEAR)) { DialogToast(""); return ""; } else if (years == calendar.get(Calendar.YEAR)) { if (month > calendar.get(Calendar.MONTH) + 1) { DialogToast(""); return ""; } else if (month == calendar.get(Calendar.MONTH) + 1) { if (day > calendar.get(Calendar.DAY_OF_MONTH)) { DialogToast(""); return ""; } } } final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogAddActivity.this); builder.setTitle(""); builder.setIcon(R.drawable.qq_dialog_default_icon);// builder.setMessage(""); builder.setPositiveButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { progressDialog = ProgressDialog.show(DailyLogAddActivity.this, "", "..."); formSubmit(); } }); builder.setNegativeButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); return "1"; }
From source file:org.yaoha.YaohaActivity.java
private void openFavMenu(final ImageButton btn, final TextView tv) { AlertDialog.Builder alert = new AlertDialog.Builder(this); final EditText input = new EditText(this); alert.setTitle("Adding favorite"); alert.setMessage("Enter your favorite search"); alert.setView(input);//from www . jav a 2 s . com alert.setPositiveButton("Set", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final Editor edit = prefs.edit(); String tmp = ""; tv.setText(input.getText()); btn.setImageResource(R.drawable.placeholder_logo); if (btn.getId() == button_favorite_1.getId()) { tmp = "saved_fav_1_text"; } else if (btn.getId() == button_favorite_2.getId()) { tmp = "saved_fav_2_text"; } else if (btn.getId() == button_favorite_3.getId()) { tmp = "saved_fav_3_text"; } else if (btn.getId() == button_favorite_4.getId()) { tmp = "saved_fav_4_text"; } else if (btn.getId() == button_favorite_5.getId()) { tmp = "saved_fav_5_text"; } else if (btn.getId() == button_favorite_6.getId()) { tmp = "saved_fav_6_text"; } edit.putString(tmp, input.getText().toString()); edit.commit(); //TODO add method to catch pre-defined store-icons } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }
From source file:com.guardtrax.ui.screens.SplashScreen.java
private void initialize() { if (locationManagerObj == null) { locationManagerObj = (LocationManager) getSystemService(Context.LOCATION_SERVICE); try {/*from w ww . j ava2s . c o m*/ gps_enabled = locationManagerObj.isProviderEnabled(LocationManager.GPS_PROVIDER); //network_enabled = locationManagerObj.isProviderEnabled(LocationManager.NETWORK_PROVIDER); } catch (Exception ex) { } } // don't start listeners if no provider is enabled - Changed to to look for both //if (!gps_enabled) if (!gps_enabled && !network_enabled) { AlertDialog.Builder dialog = new AlertDialog.Builder(SplashScreen.this); dialog.setTitle("Info"); dialog.setMessage("Please enable GPS!"); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { System.exit(0); } }); dialog.show(); } else { Runnable showWaitDialog = new Runnable() { @Override public void run() { Looper.prepare(); int i = 0; //if syncComplete is true already it means that we are not trying to sync, hence delay so that splash screen can close slowly if (syncComplete) { try { Thread.sleep(1000); } catch (Exception e) { } } else { while (!syncComplete || i++ < 10) { try { Thread.sleep(1000); } catch (Exception e) { break; } } //make sure background task is completed. If not, force it closed if (!syncComplete) { try { if (syncdb.getStatus() != AsyncTask.Status.FINISHED) syncdb.cancel(true); } catch (Exception e) { } } } //After receiving first GPS Fix dismiss the Progress Dialog dialog.dismiss(); //calling the tab class causes the current tab to be displayed (set to tab(0) which is the HomeScreen) Intent intent = new Intent(); intent.setClass(SplashScreen.this, HomeScreen.class); startActivity(intent); //transition from splash to main menu is slowed down to a fade by this command overridePendingTransition(R.anim.activityfadein, R.anim.splashfadeout); SplashScreen.this.finish(); } }; // Create a Dialog to let the User know that we're waiting for a GPS Fix dialog = ProgressDialog.show(SplashScreen.this, "Please wait", "Initializing ...", true); Thread t = new Thread(showWaitDialog); t.start(); } }