List of usage examples for android.app AlertDialog.Builder setMessage
public void setMessage(CharSequence message)
From source file:tcc.iesgo.activity.ClientMapActivity.java
@Override public void onProviderDisabled(String arg0) { final AlertDialog.Builder dialog = new AlertDialog.Builder(getParent()); dialog.setTitle(getString(R.string.gps_disabled)); dialog.setMessage(getString(R.string.gps_disabled_message)); dialog.setIcon(R.drawable.gps_enable); dialog.setCancelable(false);/*w ww. j av a 2 s . c o m*/ dialog.setPositiveButton(getString(R.string.ad_button_positive), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); } }); dialog.setNegativeButton(getString(R.string.ad_button_negative), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); finish(); } }); dialog.show(); }
From source file:org.safegees.safegees.gui.view.MainActivity.java
private void setPermissionsAlertDialog(String message) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(message).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i);//from w w w .jav a 2s.co m //finish(); } }).setNegativeButton("EXIT", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.anhuioss.crowdroid.activity.MoreFunctionActivity.java
private void confirmLogoutDialog() { AlertDialog.Builder dlg = new AlertDialog.Builder(this); dlg.setTitle(R.string.logout);/* w ww. j a va 2 s. c o m*/ dlg.setMessage(getResources().getString(R.string.wheter_to_logout)) .setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE); notificationManager.cancelAll(); Intent i = new Intent(MoreFunctionActivity.this, LoginActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.putExtra("autoLogin", false); startActivity(i); // android.os.Process // .killProcess(android.os.Process.myPid()); } }).setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .create().show(); }
From source file:com.getkickbak.plugin.NotificationPlugin.java
/** * Builds and shows a native Android confirm dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The index of the button pressed will be returned to the JavaScript callback identified by callbackId. * //from w ww .j a v a 2 s . c o m * @param message * The message the dialog should display * @param title * The title of the dialog * @param buttonLabels * A comma separated list of button labels (Up to 3 buttons) * @param callbackContext * The callback context. */ public synchronized void confirm(final String message, final String title, String buttonLabels, final CallbackContext callbackContext) { final NotificationPlugin notification = this; final CordovaInterface cordova = this.cordova; final String[] fButtons = (buttonLabels != null) ? buttonLabels.split(",") : new String[0]; Runnable runnable = new Runnable() { public void run() { AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity()); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable((fButtons.length > 0) ? true : false); // First button if (fButtons.length > 0) { dlg.setNegativeButton(fButtons[0], new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { notification.dismiss(-1, dialog); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1)); } }); dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { notification.dismiss(-1, dialog); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); } // Second button if (fButtons.length > 1) { dlg.setNeutralButton(fButtons[1], new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { notification.dismiss(-1, dialog); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2)); } }); } // Third button if (fButtons.length > 2) { dlg.setPositiveButton(fButtons[2], new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { notification.dismiss(-1, dialog); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3)); } }); } /* * dlg.setOnDismissListener(new AlertDialog.OnDismissListener() * { * public void onDismiss(DialogInterface dialog) * { * } * }); */ dlg.create(); Integer key = Integer.valueOf(((int) (Math.random() * 10000000)) + 10000); AlertDialog value = dlg.show(); notification.dialogsIA.put(key, value); notification.dialogsAI.put(value, key); if (fButtons.length == 0) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, key.intValue())); } }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.metaphyze.hackernewsfrontpage.HackerNewsFrontPageActivity.java
private void showError(String title, String error) { AlertDialog.Builder builder = new AlertDialog.Builder(HackerNewsFrontPageActivity.this); builder.setTitle(title);/*from w w w. jav a2s. c om*/ builder.setMessage(error); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
From source file:com.nuvolect.securesuite.data.SqlSyncTest.java
public void pingPongConfirmDiag(final Activity act) { m_act = act;/*from w w w. ja va2 s.c o m*/ if (!WebUtil.companionServerAssigned()) { Toast.makeText(act, "Configure companion device for test to operate", Toast.LENGTH_LONG).show(); return; } String title = "Pyramid comm test with companion device"; String message = "This is a non-destructive network performance test. " + "Payload size is incrementally increased."; AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle(title); builder.setMessage(Html.fromHtml(message)); builder.setIcon(CConst.SMALL_ICON); builder.setCancelable(true); builder.setPositiveButton("Start test", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setProgressCallback(m_act, pingPongCallbacks); pingPongProgress(act); SqlSyncTest.getInstance().init();// Small amount of init on UI thread WorkerCommand.quePingTest(m_act);// Heavy lifting on non-UI thread } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog_alert.cancel(); } }); dialog_alert = builder.create(); dialog_alert.show(); // Activate the HTML TextView tv = ((TextView) dialog_alert.findViewById(android.R.id.message)); tv.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java
public void broadcastGps() { final CharSequence[] items = { "5 minutes", "15 minutes", "1 hour", " 24 hours" }; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Choose duration of broadcast"); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, final int item) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setMessage("Enter a secret key if you want to:"); final EditText input = new EditText(getActivity()); alert.setView(input);/*from www . j a va 2s . co m*/ alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final String password = input.getText().toString(); myLocation = new MyLocation(); locationResult = new MyLocation.LocationResult() { final ProgressDialog dialog = ProgressDialog.show(getActivity(), "", "Preparing broadcast...", true); @Override public void gotLocation(final Location location) { //Got the location! try { int minutes; if (item == 0) { minutes = 5; } else if (item == 1) { minutes = 15; } else if (item == 2) { minutes = 60; } else if (item == 3) { minutes = 1440; } else { minutes = 5; } Uri uri = new Uri.Builder().scheme("http").authority("suif.stanford.edu") .path("dungbeetle/nearby.php").build(); StringBuffer sb = new StringBuffer(); DefaultHttpClient client = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(uri.toString()); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("group_name", mGroupName)); nameValuePairs .add(new BasicNameValuePair("feed_uri", mExternalFeedUri.toString())); nameValuePairs.add(new BasicNameValuePair("length", Integer.toString(minutes))); nameValuePairs.add( new BasicNameValuePair("lat", Double.toString(location.getLatitude()))); nameValuePairs.add(new BasicNameValuePair("lng", Double.toString(location.getLongitude()))); nameValuePairs.add(new BasicNameValuePair("password", password)); httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); try { HttpResponse execute = client.execute(httpPost); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { sb.append(s); } } catch (Exception e) { e.printStackTrace(); } String response = sb.toString(); if (response.equals("1")) { Toast.makeText(getActivity(), "Now broadcasting for " + items[item], Toast.LENGTH_SHORT).show(); } else Log.w(TAG, "Wtf"); Log.w(TAG, "response: " + response); } catch (Exception e) { } dialog.dismiss(); } }; locationClick(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.grupohqh.carservices.operator.ShowCarActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show_car); if (getIntent().getExtras().containsKey("carId")) carId = getIntent().getExtras().getInt("carId"); if (getIntent().getExtras().containsKey("userId")) userId = getIntent().getExtras().getInt("userId"); CAR_URL = getString(R.string.base_url) + getString(R.string.car_url); COMPLETESEVICEORDER_URL = getString(R.string.base_url) + "completeserviceorder/"; serviceButtons = findViewById(R.id.serviceButtons); txtOwnerName = (TextView) findViewById(R.id.txtOwnerName); txtTag = (TextView) findViewById(R.id.txtTag); txtCarBrand = (TextView) findViewById(R.id.txtCarBrand); txtModel = (TextView) findViewById(R.id.txtCarModel); txtYear = (TextView) findViewById(R.id.txtCarYear); txtSerialNumber = (TextView) findViewById(R.id.txtSerialNumber); txtLicensePlate = (TextView) findViewById(R.id.txtLicensePlate); txtColor = (TextView) findViewById(R.id.txtColor); txtKM = (TextView) findViewById(R.id.txtKM); imgCar = (ImageView) findViewById(R.id.imgCar); imgBlur = (ImageView) findViewById(R.id.imgBlur); btnOrderService = (Button) findViewById(R.id.btnOrderService); btnConfigurationCar = (Button) findViewById(R.id.btnConfigurationCar); btnInventory = (Button) findViewById(R.id.btnInventory); btnDiagnostic = (Button) findViewById(R.id.btnDiagnostic); btnQuote = (Button) findViewById(R.id.btnQuote); btnCompletion = (Button) findViewById(R.id.btnCompletion); defaultBg = btnConfigurationCar.getBackground().getConstantState().newDrawable(); btnOrderService.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a v a 2 s. c o m public void onClick(View v) { Intent intent = new Intent(getBaseContext(), ServiceOrderActivity.class); intent.putExtra("carId", carId); intent.putExtra("userId", userId); startActivity(intent); } }); btnConfigurationCar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getBaseContext(), ConfigurationKMCaptureActivity.class); intent.putExtra("carId", carId); intent.putExtra("userId", userId); startActivity(intent); } }); btnInventory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getBaseContext(), ServiceOrderLevelsActivity.class); intent.putExtra("serviceOrderId", serviceOrderId); intent.putExtra("userId", userId); startActivity(intent); } }); btnDiagnostic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getBaseContext(), ServiceDiagnosticActivity.class); intent.putExtra("serviceOrderId", serviceOrderId); intent.putExtra("userId", userId); startActivity(intent); } }); btnCompletion.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: new CompleteServiceAsyncTask().execute(COMPLETESEVICEORDER_URL); dialog.dismiss(); break; case DialogInterface.BUTTON_NEGATIVE: dialog.dismiss(); break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ShowCarActivity.this); builder.setMessage("Finalizar el servicio tcnico?").setPositiveButton("Si", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } }); }
From source file:org.dvbviewer.controller.ui.fragments.TaskList.java
@Override public void onListItemClick(ListView parent, View view, int position, long id) { selectedTask = (Task) sAdapter.getItem(position); if (selectedTask.getCommand().equals(WOL_COMMAND)) { /**//from w w w . j a va 2 s. co m * Try to wake Recording Service */ Runnable wakeOnLanRunnabel = new Runnable() { @Override public void run() { NetUtils.sendWakeOnLan(ServerConsts.REC_SERVICE_HOST, ServerConsts.REC_SERVICE_MAC_ADDRESS); } }; Thread wakeOnLanThread = new Thread(wakeOnLanRunnabel); wakeOnLanThread.start(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); String question = MessageFormat.format( getResources().getString(R.string.task_execute_security_question), selectedTask.getTitle()); builder.setMessage(question).setPositiveButton("Yes", this).setTitle(R.string.dialog_confirmation_title) .setNegativeButton("No", this).show(); } }
From source file:com.sourcey.materiallogindemo.PostItemActivity.java
private void DialogRequest(final String map_id, final String passenger) { View dialogBoxView = View.inflate(this, R.layout.dialog_request, null); final Button btnMap = (Button) dialogBoxView.findViewById(R.id.btnMap); final Button btnRequest = (Button) dialogBoxView.findViewById(R.id.btnRequest); btnMap.setOnClickListener(new View.OnClickListener() { @Override/* w w w .j a v a 2 s . co m*/ public void onClick(View v) { DialogMap(); } }); btnRequest.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if ("CAR".equals(type)) { saveRequest(map_id, user_id); } else if ("NOCAR".equals(type)) { saveRequest(map_id, passenger); } else { MessageDialog("!!"); } } }); /* String url = getString(R.string.url_map)+"index.php?poinFrom="+txtStart.getText().toString().trim()+"&poinTo="+txtEnd.getText().toString().trim(); map.getSettings().setLoadsImagesAutomatically(true); map.getSettings().setJavaScriptEnabled(true); map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); map.loadUrl(url);*/ AlertDialog.Builder builderInOut = new AlertDialog.Builder(this); builderInOut.setTitle("?"); builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false) .setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).show(); }