List of usage examples for android.app AlertDialog show
public void show()
From source file:com.sck.maininterface.PaymentInfo.java
@SuppressWarnings("deprecation") @Override/* ww w . j a v a 2 s . c om*/ protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_PAYMENT) { if (resultCode == Activity.RESULT_OK) { PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); if (confirm != null) { try { Log.i(TAG, confirm.toJSONObject().toString(4)); Log.i(TAG, confirm.getPayment().toJSONObject().toString(4)); /* Toast.makeText( getApplicationContext(), "Payment Confirmation info received from PayPal", Toast.LENGTH_LONG).show();*/ AlertDialog ad = new AlertDialog.Builder(this).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("Payment Confirmation info received from PayPal"); ad.setButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.show(); //new updateExpiryDate().execute(); //paymentSuccess=true; saveExpDate(renewedDate); } catch (JSONException e) { Log.e(TAG, "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i(TAG, "The user canceled."); } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); } } // / }
From source file:cm.aptoide.pt.Aptoide.java
private void downloadServ(String srv) { try {/*w w w . j a va 2s .c o m*/ keepScreenOn.acquire(); BufferedInputStream getit = new BufferedInputStream(new URL(srv).openStream()); File file_teste = new File(TMP_SRV_FILE); if (file_teste.exists()) file_teste.delete(); FileOutputStream saveit = new FileOutputStream(TMP_SRV_FILE); BufferedOutputStream bout = new BufferedOutputStream(saveit, 1024); byte data[] = new byte[1024]; int readed = getit.read(data, 0, 1024); while (readed != -1) { bout.write(data, 0, readed); readed = getit.read(data, 0, 1024); } keepScreenOn.release(); bout.close(); getit.close(); saveit.close(); } catch (Exception e) { AlertDialog p = new AlertDialog.Builder(this).create(); p.setTitle(getText(R.string.top_error)); p.setMessage(getText(R.string.aptoide_error)); p.setButton(getText(R.string.btn_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); p.show(); } }
From source file:com.df.kia.carsWaiting.CarsWaitingListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cars_waiting); swipeListView = (SwipeListView) findViewById(R.id.carsWaitingList); data = new ArrayList<CarsWaitingItem>(); adapter = new CarsWaitingListAdapter(this, data, new CarsWaitingListAdapter.OnAction() { @Override/*from ww w .j a va 2 s .c o m*/ public void onEditPressed(int position) { swipeListView.openAnimate(position); } @Override public void onModifyProcedure(int positon) { CarsWaitingItem item = data.get(positon); Intent intent = new Intent(CarsWaitingListActivity.this, InputProceduresActivity.class); intent.putExtra("carId", item.getCarId()); startActivity(intent); } @Override public void onDeleteCar(final int position) { View view1 = getLayoutInflater().inflate(R.layout.popup_layout, null); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); TextView content = new TextView(view1.getContext()); content.setText(R.string.confirmDeleteCar); content.setTextSize(20f); contentArea.addView(content); setTextView(view1, R.id.title, getResources().getString(R.string.alert)); AlertDialog dialog = new AlertDialog.Builder(CarsWaitingListActivity.this).setView(view1) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { CarsWaitingItem item = data.get(position); deleteCar(item.getCarId()); } }).setNegativeButton(R.string.cancel, null).create(); dialog.show(); } }); swipeListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() { @Override public void onClickFrontView(int position) { getCarDetail(data.get(position).getCarId(), CarCheckActivity.class); } @Override public void onDismiss(int[] reverseSortedPositions) { for (int position : reverseSortedPositions) { data.remove(position); } adapter.notifyDataSetChanged(); } @Override public void onStartOpen(int position, int action, boolean right) { swipeListView.closeOpenedItems(); lastPos = position; } }); swipeListView.setSwipeMode(SwipeListView.SWIPE_MODE_LEFT); swipeListView.setSwipeActionLeft(SwipeListView.SWIPE_ACTION_REVEAL); swipeListView.setLongClickable(false); swipeListView.setSwipeOpenOnLongPress(false); swipeListView.setOffsetLeft(620); swipeListView.setAnimationTime(300); swipeListView.setAdapter(adapter); footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.footer, null, false); swipeListView.addFooterView(footerView); Button homeButton = (Button) findViewById(R.id.buttonHome); homeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); Button loadMoreButton = (Button) findViewById(R.id.loadMore); loadMoreButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { refresh(); } }); Button refreshButton = (Button) findViewById(R.id.buttonRefresh); refreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startNumber = 1; data.clear(); adapter.notifyDataSetChanged(); swipeListView.closeOpenedItems(); refresh(); } }); refresh(); }
From source file:com.snt.bt.recon.activities.MainActivity.java
private void buildAlertMessageNoGps() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Your GPS is currently disabled, do you want to manually enable it?") .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); }/*w ww . j ava2 s . c om*/ }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); //close app finishAffinity(); } }); final AlertDialog alert = builder.create(); alert.show(); }
From source file:com.aikidonord.Intervenant.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_intervenant); View rlLoading = findViewById(R.id.loadingPanel); View listView = findViewById(R.id.list); ActionBar actionBar = this.getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(getResources().getString(R.string.actionbar_titre_intervenant)); if (VerifConnexion.isOnline(this)) { rlLoading.setVisibility(View.VISIBLE); listView.setVisibility(View.GONE); new QueryForAnimateurTask().execute(this, this.getApplicationContext()); } else {// w w w . jav a 2 s . c o m AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getResources().getString(R.string.app_name)); alertDialog.setMessage(getResources().getString(R.string.no_network)); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setCancelable(false); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, close // current activity Intervenant.this.finish(); } }); alertDialog.show(); } }
From source file:com.miuidev.themebrowser.MainActivity.java
private void displayAbout() { AlertDialog.Builder builder;// w w w.j a v a2 s . c o m AlertDialog alertDialog; LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.dialog_about, (ViewGroup) findViewById(R.id.DialogAboutRelativeLayout)); TextView text = (TextView) layout.findViewById(R.id.AboutVersionValue); text.setText(getVersionName()); builder = new AlertDialog.Builder(this); builder.setView(layout); builder.setCancelable(false).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alertDialog = builder.create(); alertDialog.show(); }
From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java
/** * ??Select//from w w w. ja va 2 s . com * * @param title * @param text * @return */ public int showAndroidSelect(final String title, final String text[]) { Runnable showSelect = new Runnable() { public void run() { final AlertDialog.Builder builder = new AlertDialog.Builder(LGameAndroid2DActivity.this); builder.setTitle(title); builder.setItems(text, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { androidSelect = item; } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { androidSelect = -1; } }); AlertDialog alert = builder.create(); alert.show(); } }; runOnUiThread(showSelect); return androidSelect; }
From source file:com.swetha.easypark.DisplayVacantParkingLots.java
@SuppressWarnings("deprecation") public void updatemap(ArrayList<HashMap<String, String>> alofHashmap, int Success) { if (success == 1) { try {/*from w w w . ja v a2s.c om*/ googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.parkinglotsmap)) .getMap(); IconGenerator ig = new IconGenerator(this); googleMap.clear(); for (int i = (alofHashmap.size() - 1); i >= 0; i--) { //canvas.drawText(alofHashmap.get(i).get("costForParking"), 0, 40, paint); LatLng latLng = new LatLng(Double.parseDouble(alofHashmap.get(i).get("latitude")), Double.parseDouble(alofHashmap.get(i).get("longitude"))); Bitmap bmp = ig.makeIcon(alofHashmap.get(i).get("costForParking")); googleMap.addMarker(new MarkerOptions().position(latLng) //.title() //.snippet(alofHashmap.get(i).get("lotsInfoTextView")) .icon(BitmapDescriptorFactory.fromBitmap(bmp))).showInfoWindow(); //.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_car))).showInfoWindow(); googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); googleMap.animateCamera(CameraUpdateFactory.zoomTo(15)); } googleMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker arg0) { LatLng markerLatLng = arg0.getPosition(); Log.i("DisplayVacantParkingLots", "Value of the marker that was clicked is" + markerLatLng.toString()); for (int i = (parkingLotsMapList.size() - 1); i >= 0; i--) { Log.i("DisplayVacantParkingLots", "value in the parkinglots map inside for loop" + parkingLotsMapList.get(i).toString()); if (parkingLotsMapList.get(i).containsValue(String.valueOf(markerLatLng.latitude)) && parkingLotsMapList.get(i) .containsValue(String.valueOf(markerLatLng.longitude))) { Intent intent = new Intent(DisplayVacantParkingLots.this, GetIndividualParkingSpotDetails.class); intent.putExtra("individualParkingLotId", parkingLotsMapList.get(i).get("vacantParkingLotId")); Log.i("DisplayVacantParkingLots", "The value of the parkinglot of the marker clicked is" + parkingLotsMapList.get(i).get("vacantParkingLotId")); intent.putExtra(GetParkingLots.FROMTIME, DisplayVacantParkingLots.fromTime); intent.putExtra(GetParkingLots.TOTIME, DisplayVacantParkingLots.toTime); startActivity(intent); } } return true; } }); } catch (Exception e) { } finally { } } else { AlertDialog alertDialog = new AlertDialog.Builder(DisplayVacantParkingLots.this).create(); alertDialog.setTitle("Sorry!"); alertDialog.setMessage("No parking lots found"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Intent intent = new Intent(DisplayVacantParkingLots.this, GetParkingLots.class); startActivity(intent); } }); alertDialog.show(); } }
From source file:net.networksaremadeofstring.cyllell.ViewCookbooks_Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { settings = this.getActivity().getSharedPreferences("Cyllell", 0); try {/*from ww w. j a v a2 s .c o m*/ Cut = new Cuts(getActivity()); } catch (Exception e) { e.printStackTrace(); } dialog = new ProgressDialog(getActivity()); dialog.setTitle("Contacting Chef"); dialog.setMessage("Please wait: Prepping Authentication protocols"); dialog.setIndeterminate(true); if (listOfCookbooks.size() < 1) { dialog.show(); } updateListNotify = new Handler() { public void handleMessage(Message msg) { int tag = msg.getData().getInt("tag", 999999); if (msg.what == 0) { if (tag != 999999) { listOfCookbooks.get(tag).SetSpinnerVisible(); } } else if (msg.what == 1) { //Get rid of the lock CutInProgress = false; //the notifyDataSetChanged() will handle the rest } else if (msg.what == 99) { if (tag != 999999) { Toast.makeText(ViewCookbooks_Fragment.this.getActivity(), "An error occured during that operation.", Toast.LENGTH_LONG).show(); listOfCookbooks.get(tag).SetErrorState(); } } CookbookAdapter.notifyDataSetChanged(); } }; handler = new Handler() { public void handleMessage(Message msg) { //Once we've checked the data is good to use start processing it if (msg.what == 0) { OnClickListener listener = new OnClickListener() { public void onClick(View v) { GetMoreDetails((Integer) v.getTag()); } }; OnLongClickListener listenerLong = new OnLongClickListener() { public boolean onLongClick(View v) { //selectForCAB((Integer)v.getTag()); Toast.makeText(getActivity(), "This version doesn't support Cookbook editing yet", Toast.LENGTH_SHORT).show(); return true; } }; CookbookAdapter = new CookbookListAdaptor(getActivity(), listOfCookbooks, listener, listenerLong); try { list = (ListView) getView().findViewById(R.id.cookbooksListView); } catch (Exception e) { e.printStackTrace(); } if (list != null) { if (CookbookAdapter != null) { list.setAdapter(CookbookAdapter); } else { //Log.e("CookbookAdapter","CookbookAdapter is null"); } } else { //Log.e("List","List is null"); } dialog.dismiss(); } else if (msg.what == 200) { dialog.setMessage("Sending request to Chef..."); } else if (msg.what == 201) { dialog.setMessage("Parsing JSON....."); } else if (msg.what == 202) { dialog.setMessage("Populating UI!"); } else { //Close the Progress dialog dialog.dismiss(); //Alert the user that something went terribly wrong AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle("API Error"); alertDialog.setMessage("There was an error communicating with the API:\n" + msg.getData().getString("exception")); alertDialog.setButton2("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //getActivity().finish(); } }); alertDialog.setIcon(R.drawable.icon); alertDialog.show(); } } }; Thread dataPreload = new Thread() { public void run() { if (listOfCookbooks.size() > 0) { handler.sendEmptyMessage(0); } else { try { handler.sendEmptyMessage(200); Cookbooks = Cut.GetCookbooks(); handler.sendEmptyMessage(201); JSONArray Keys = Cookbooks.names(); String URI = ""; String Version = "0.0.0"; JSONObject cookbook; for (int i = 0; i < Cookbooks.length(); i++) { cookbook = new JSONObject(Cookbooks.getString(Keys.get(i).toString())); //URI = Cookbooks.getString(Keys.get(i).toString()).replaceFirst("^(https://|http://).*/cookbooks/", ""); //Version = Cookbooks.getString(Keys.get(i).toString()) //Log.i("Cookbook Name", Keys.get(i).toString()); URI = cookbook.getString("url").replaceFirst("^(https://|http://).*/cookbooks/", ""); //Log.i("Cookbook URL", URI); JSONArray versions = cookbook.getJSONArray("versions"); Version = versions.getJSONObject(versions.length() - 1).getString("version"); //Log.i("Cookbook version", Version); listOfCookbooks.add(new Cookbook(Keys.get(i).toString(), URI, Version)); } handler.sendEmptyMessage(202); handler.sendEmptyMessage(0); } catch (Exception e) { BugSenseHandler.log("ViewCookbooksFragment", e); e.printStackTrace(); Message msg = new Message(); Bundle data = new Bundle(); data.putString("exception", e.getMessage()); msg.setData(data); msg.what = 1; handler.sendMessage(msg); } } return; } }; dataPreload.start(); return inflater.inflate(R.layout.cookbooks_landing, container, false); }
From source file:com.TakeTaxi.jy.OnrouteScreen.java
public void alertdialog_drivercancelintime() { AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create(); dcancelbuilder.setMessage("Job has been cancelled.\nPlease look for another driver."); dcancelbuilder.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent openStart = new Intent("com.TakeTaxi.jy.TakeTaxiActivity"); startActivity(openStart);// www . ja va2s. c o m } }); dcancelbuilder.show(); }