List of usage examples for android.widget Toast show
public void show()
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
public void imageSharing(Intent data, String type) { // Get the Uri of the selected file Uri uri = data.getData();/*from w ww. j a v a2 s . c om*/ Log.d("imageSharing - type", type + " @"); Log.d("File Uri: ", uri.toString() + " #"); // Get the path String path = null; try { path = getPath(this, uri); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("File Path: ", path + " #"); if (path != null) { String userNum = prefs.getString(stored_user_country_code, "") + prefs.getString(stored_user_mobile_no, ""); String fileName = System.currentTimeMillis() + getFileFormat(path); String msg; if (type.equals("video")) { msg = "VID-" + userNum + "-" + fileName; } else if (type.equals("audio")) { msg = "AUD-" + userNum + "-" + fileName; } else { msg = "IMG-" + userNum + "-" + fileName; } String numb = prefs.getString(stored_chatuserNumber, ""); Log.d("nnumb", numb + " #"); String savefileuri = saveImage(path, fileName, stripNumber(numb)); if (savefileuri.equals(FILE_SIZE_ERROR + "")) { Toast toast = Toast.makeText(getApplicationContext(), "you upload file size is exceed to 30 MB", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } else if (!savefileuri.equals("")) { Log.d("msg1", msg + " !"); sendInitmsg(msg, numb); new AsyncTaskUploadFile(savefileuri, msg).execute(); } else { Toast.makeText(getApplicationContext(), "File not found", Toast.LENGTH_SHORT).show(); } } }
From source file:com.ccxt.whl.activity.ChatActivity.java
/** * ?uri??/*from w w w . j av a2 s.c o m*/ * * @param selectedImage */ private void sendPicByUri(Uri selectedImage) { // String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(picturePath); } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(file.getAbsolutePath()); } }
From source file:reportsas.com.formulapp.Formulario.java
public void enviarR(View v) { String resul = ""; SharedPreferences pref = getSharedPreferences("ParametrosBasicos", Context.MODE_PRIVATE); long per = pref.getInt("userid", 0); respuestaEncuesta = new EncuestaRespuesta(encuesta.getIdEncuesta(), per, Integer.parseInt(getDatePhone("MMddHHmmss")), "" + getDatePhone("yyyy-MM-dd")); ArrayList<PreguntaRespuesta> respuestas = new ArrayList<PreguntaRespuesta>(); ArrayList<ParametrosRespuesta> respuestaParametros = new ArrayList<ParametrosRespuesta>(); boolean validator = false; for (int i = 0; i < layout.getChildCount(); i++) { LinearLayout child = (LinearLayout) layout.getChildAt(i); int numeRes = ObtenerRespuesta(child, encuesta.getPreguntas().get(i), respuestas); if (encuesta.getPreguntas().get(i).getObligatoria().equals("S")) { for (int j = respuestas.size() - 1; j > (respuestas.size() - 1) - numeRes; j--) { PreguntaRespuesta respuestaValidar = respuestas.get(j); if (respuestaValidar.getOpcion() == null) { if (respuestaValidar.getRespuesta().trim().length() == 0) { Toast toast1 = Toast.makeText(this, "La pregunta :" + encuesta.getPreguntas().get(i).getTitulo() + ", Es obligatoria!", Toast.LENGTH_LONG); toast1.show(); validator = true; }/*from ww w .j ava 2s . c o m*/ } else { if (respuestaValidar.getOpcion().trim().length() == 0) { Toast toast1 = Toast.makeText(this, "Debe escoger un valor para " + respuestaValidar.getRespuesta() + " en la pregunta :" + encuesta.getPreguntas().get(i).getTitulo(), Toast.LENGTH_LONG); toast1.show(); validator = true; } } } } if (validator) { respuestas.clear(); break; } } if (encuesta.getParametros() != null) { for (int w = 0; w < encuesta.getParametros().size(); w++) { EncuestaParametro ep = encuesta.getParametros().get(w); if (ep.getOpcional().indexOf('N') > -1) { switch (ep.getIdParametro()) { // Captura GPS case 1: if (parametroGPS == null) { Toast toast1 = Toast.makeText(this, "Debe diligenciar la ubicacin GPS ", Toast.LENGTH_LONG); toast1.show(); validator = true; } break; // Captura Imgen case 2: if (parametroCam == null) { Toast toast1 = Toast.makeText(this, "Debe obtener la captura de una imagen.", Toast.LENGTH_LONG); toast1.show(); validator = true; } break; // Lectura de Codigo case 3: if (parametroScan == null) { Toast toast1 = Toast.makeText(this, "Debe obtener el scaner de la cedula", Toast.LENGTH_LONG); toast1.show(); validator = true; } break; default: break; } if (validator) { break; } } } if (!validator) { if (parametroGPS != null) { respuestaParametros.add(parametroGPS); } if (parametroCam != null) { respuestaParametros.add(parametroCam); } if (parametroScan != null) { respuestaParametros.add(parametroScan); } if (respuestas.size() > 0) { respuestaEncuesta.setRespuesta(respuestas); if (respuestaParametros.size() > 0) { respuestaEncuesta.setParametros(respuestaParametros); } } } } if (!validator) { final Gson gson = new Gson(); if (DataOpciones.verificaConexion(this)) { String pr = pref.getString("ruta", "54.164.174.129:8081"); //http://10.200.5.8:8081/ String ruta = "http://" + pr + "/" + HTTP_EVENT; new MyAsyncTask(Formulario.this).execute("POST", gson.toJson(respuestaEncuesta), ruta); } else { insertarEncuentas(respuestaEncuesta); } } }
From source file:reportsas.com.formulapp.Formulario.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (data != null) { if (data.hasExtra("data")) { Bitmap photobmp = (Bitmap) data.getParcelableExtra("data"); // iv.setImageBitmap(photobmp); ByteArrayOutputStream baos = new ByteArrayOutputStream(); photobmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] imageBytes = baos.toByteArray(); String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); if (parametroCam == null) { parametroCam = new ParametrosRespuesta(2); }//from w ww . j av a 2 s .co m parametroCam.setValor(encodedImage); // prueba.setText(encodedImage); // new MyAsyncTask(Formulario.this) // .execute("POST",encodedImage, HTTP_EVENT); } } } if (requestCode == MY_REQUEST_CODE && resultCode == Pdf417ScanActivity.RESULT_OK) { // First, obtain scan results array. If scan was successful, array will contain at least one element. // Multiple element may be in array if multiple scan results from single image were allowed in settings. Parcelable[] resultArray = data .getParcelableArrayExtra(Pdf417ScanActivity.EXTRAS_RECOGNITION_RESULT_LIST); StringBuilder sb = new StringBuilder(); for (Parcelable p : resultArray) { if (p instanceof Pdf417ScanResult) { // check if scan result is result of Pdf417 recognizer Pdf417ScanResult result = (Pdf417ScanResult) p; // getStringData getter will return the string version of barcode contents String barcodeData = result.getStringData(); // isUncertain getter will tell you if scanned barcode contains some uncertainties boolean uncertainData = result.isUncertain(); // getRawData getter will return the raw data information object of barcode contents BarcodeDetailedData rawData = result.getRawData(); // BarcodeDetailedData contains information about barcode's binary layout, if you // are only interested in raw bytes, you can obtain them with getAllData getter byte[] rawDataBuffer = rawData.getAllData(); DataR = rawData.toString(); String[] arrayElements = DataR.split("Element #"); String Nombre = "", Apellido = "", cedula = "", fecha = "", dia, mes, ano; if (arrayElements.length >= 7) { String[] auxliarArray = arrayElements[7].split("decoded\\):"); String strDatos = auxliarArray[1]; char[] ca = strDatos.toCharArray(); for (int i = 0; i < strDatos.length(); i++) { if (Character.isLetter(ca[i])) //Si es letra Apellido += ca[i]; //Salto de lnea e imprimimos el carcter else //Si no es letra cedula += ca[i]; //Imprimimos el carcter } Apellido = Apellido.trim(); cedula = (cedula.replaceAll("\n", "")).trim(); if (cedula.length() == 0) { auxliarArray = arrayElements[5].split("decoded\\):"); strDatos = auxliarArray[1]; ca = strDatos.toCharArray(); Apellido = ""; for (int i = 0; i < strDatos.length(); i++) { if (Character.isLetter(ca[i])) //Si es letra Apellido += ca[i]; //Salto de lnea e imprimimos el carcter else //Si no es letra cedula += ca[i]; //Imprimimos el carcter } Apellido = Apellido.trim(); cedula = (cedula.replaceAll("\n", "")).trim(); cedula = cedula.substring(cedula.length() - 10, cedula.length()); cedula = eliminarceros(cedula); auxliarArray = arrayElements[9].split("decoded\\):"); Nombre = (auxliarArray[1].replaceAll("\n", "")).trim(); } else { cedula = eliminarceros(cedula); auxliarArray = arrayElements[11].split("decoded\\):"); Nombre = (auxliarArray[1].replaceAll("\n", "")).trim(); } auxliarArray = result.getStringData().toString().split(Nombre); strDatos = auxliarArray[1]; ca = strDatos.toCharArray(); Boolean result_ciclo = true; int i = 0; while (result_ciclo) { if (Character.isDigit(ca[i])) { fecha += ca[i]; } if (fecha.length() >= 9) { result_ciclo = false; } i++; } fecha = fecha.substring(1, fecha.length()); } else { int puntoI = 0; if (barcodeData.indexOf("1F") > 0) { puntoI = barcodeData.indexOf("1F"); } else if (barcodeData.indexOf("0M") > 0) { puntoI = barcodeData.indexOf("0M"); } else if (barcodeData.indexOf("0F") > 0) { puntoI = barcodeData.indexOf("0F"); } else if (barcodeData.indexOf("1M") > 0) { puntoI = barcodeData.indexOf("1M"); } else { } if (puntoI > 0) { String seb = barcodeData.substring(1, puntoI); fecha = barcodeData.substring(puntoI + 2, puntoI + 10); int posL = 0, posE; char[] ca = seb.toCharArray(); for (int w = seb.length() - 1; w > 0; w--) { if (Character.isLetter(ca[w])) { posL = w; break; } } seb = seb.substring(1, posL + 1); ca = seb.toCharArray(); for (int w = seb.length() - 1; w > 0; w--) { if (Character.isLetter(ca[w])) { Nombre = ca[w] + Nombre; posL = w; } else { break; } } seb = seb.substring(1, posL); ca = seb.toCharArray(); for (int w = seb.length() - 1; w > 0; w--) { if (Character.isDigit(ca[w])) { posL = w; break; } } for (int w = posL + 1; w <= seb.length(); w++) { if (Character.isLetter(ca[w])) { Apellido += ca[w]; } else { break; } } cedula = seb.substring(posL - 9, posL + 1); cedula = eliminarceros(cedula); } else { fecha = ""; } } if (fecha.length() == 0) { parametroScan = null; Toast toast1 = Toast.makeText(this, "Los datos de codigo no pudieron ser interpretados!", Toast.LENGTH_SHORT); toast1.show(); } else { dia = fecha.substring(6, 8); mes = fecha.substring(4, 6); ano = fecha.substring(0, 4); fecha = dia + "/" + mes + "/" + ano; Infocadena = "Nombre: \n" + Nombre + ".\nApellido: \n" + Apellido + ". \nCedula: \n" + cedula + ". \nFecha de Nacimiento: \n" + fecha + "."; if (parametroScan == null) { parametroScan = new ParametrosRespuesta(3); } parametroScan.setValor(Infocadena); } // new MyAsyncTask(Formulario.this) // .execute("POST",Infocadena, HTTP_EVENT); } else if (p instanceof BarDecoderScanResult) { // check if scan result is result of BarDecoder recognizer /* BarDecoderScanResult result = (BarDecoderScanResult) p; // with getBarcodeType you can obtain barcode type enum that tells you the type of decoded barcode BarcodeType type = result.getBarcodeType(); // as with PDF417, getStringData will return the string contents of barcode String barcodeData = result.getStringData(); if(checkIfDataIsUrlAndCreateIntent(barcodeData)) { return; } else { sb.append(type.name()); sb.append(" string data:\n"); sb.append(barcodeData); sb.append("\n\n\n");= }*/ } else if (p instanceof ZXingScanResult) { // check if scan result is result of ZXing recognizer /* ZXingScanResult result= (ZXingScanResult) p; // with getBarcodeType you can obtain barcode type enum that tells you the type of decoded barcode BarcodeType type = result.getBarcodeType(); // as with PDF417, getStringData will return the string contents of barcode String barcodeData = result.getStringData(); if(checkIfDataIsUrlAndCreateIntent(barcodeData)) { return; } else { sb.append(type.name()); sb.append(" string data:\n"); sb.append(barcodeData); sb.append("\n\n\n"); }*/ } else if (p instanceof USDLScanResult) { // check if scan result is result of US Driver's Licence recognizer USDLScanResult result = (USDLScanResult) p; // USDLScanResult can contain lots of information extracted from driver's licence // you can obtain information using the getField method with keys defined in // USDLScanResult class String name = result.getField(USDLScanResult.kCustomerFullName); sb.append(result.getTitle()); sb.append("\n\n"); sb.append(result.toString()); } } } }
From source file:co.taqat.call.CallActivity.java
public void displayCustomToast(final String message, final int duration) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot)); TextView toastText = (TextView) layout.findViewById(R.id.toastMessage); toastText.setText(message);/*from w w w. j ava2 s . com*/ final Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(duration); toast.setView(layout); toast.show(); }
From source file:biz.incomsystems.fwknop2.ConfigDetailFragment.java
public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.detail_help) { Intent detailIntent = new Intent(getActivity(), HelpActivity.class); startActivity(detailIntent);//from w w w .java 2s. c o m } else if (id == R.id.qr_code) { try { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); // "PRODUCT_MODE for bar codes startActivityForResult(intent, 0); } catch (Exception e) { // This is where the play store is called if the app is not installed Uri marketUri = Uri.parse("market://details?id=com.google.zxing.client.android"); Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri); startActivity(marketIntent); } } else if (id == R.id.save) { InetAddressValidator ipValidate = new InetAddressValidator(); Context context = getActivity(); // We know we will use a toast, so set it up now int duration = Toast.LENGTH_LONG; CharSequence text = "Saving config"; Toast toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); LinearLayout toastLayout = (LinearLayout) toast.getView(); TextView toastTV = (TextView) toastLayout.getChildAt(0); toastTV.setTextSize(30); //The following is all input validation try { if ((Integer.parseInt(txt_server_port.getText().toString()) > 0) && (Integer.parseInt(txt_server_port.getText().toString()) < 65535)) { // check for valid port txt_server_port.setText(String.valueOf(Integer.parseInt(txt_server_port.getText().toString()))); } else { txt_server_port.setText(String.valueOf(62201)); } } catch (NumberFormatException ex) { txt_server_port.setText(String.valueOf(62201)); } if (txt_NickName.getText().toString().equalsIgnoreCase("")) { // Need to create a new Nick toast.setText("You Must choose a unique Nickname."); // choosing a used nick will just overwrite it. So really toast.show(); } else if (chkb64hmac.isChecked() && txt_HMAC.getText().toString().length() % 4 != 0) { // base64 must have a multiple of 4 length toast.setText("Hmac is not a valid Base64, not a multiple of 4."); toast.show(); } else if (chkb64hmac.isChecked() && !(txt_HMAC.getText().toString().matches("^[A-Za-z0-9+/]+={0,2}$"))) { // looks for disallowed b64 characters toast.setText("Hmac is not a valid Base64, Contains disallowed characters."); toast.show(); } else if (chkb64key.isChecked() && txt_KEY.getText().toString().length() % 4 != 0) { toast.setText("Key is not a valid Base64, not a multiple of 4."); toast.show(); } else if (chkb64key.isChecked() && !(txt_KEY.getText().toString().matches("^[A-Za-z0-9+/]+={0,2}$"))) { // looks for disallowed b64 characters toast.setText("Key is not a valid Base64, Contains disallowed characters."); toast.show(); } else if (!(txt_ports.getText().toString().matches("tcp/\\d.*") || txt_ports.getText().toString().matches("udp/\\d.*"))) { toast.setText("Access ports must be in the form of 'tcp/22'"); toast.show(); } else if (spn_allowip.getSelectedItem().toString().equalsIgnoreCase("Allow IP") && (!ipValidate.isValid(txt_allowIP.getText().toString()))) { //Have to have a valid ip to allow, if using allow ip toast.setText("You Must supply a valid IP address to 'Allow IP'."); toast.show(); } else if (!ipValidate.isValid(txt_server_ip.getText().toString()) && !DomainValidator.getInstance().isValid(txt_server_ip.getText().toString())) { // check server entry. Must be a valid url or ip. toast.setText("You Must supply a valid server address."); toast.show(); } else if (txt_KEY.getText().toString().equalsIgnoreCase("")) { toast.setText("You Must supply a Rijndael key."); toast.show(); } else if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("Juicessh") && juice_adapt.getConnectionName(spn_juice.getSelectedItemPosition()) == null) { toast.setText("A connection must be saved in Juicessh before being used here."); toast.show(); // //end input validation, actual saving below } else { toast.show(); if (configtype.equalsIgnoreCase("Open Port")) { config.PORTS = txt_ports.getText().toString(); config.SERVER_TIMEOUT = txt_server_time.getText().toString(); } else { config.PORTS = ""; config.SERVER_TIMEOUT = ""; } if (configtype.equalsIgnoreCase("Nat Access")) { config.NAT_IP = txt_nat_ip.getText().toString(); config.NAT_PORT = txt_nat_port.getText().toString(); config.PORTS = txt_ports.getText().toString(); config.SERVER_TIMEOUT = txt_server_time.getText().toString(); } else { config.NAT_IP = ""; config.NAT_PORT = ""; } if (configtype.equalsIgnoreCase("Server Command")) { config.SERVER_CMD = txt_server_cmd.getText().toString(); } else { config.SERVER_CMD = ""; } if (spn_allowip.getSelectedItem().toString().equalsIgnoreCase("Resolve IP")) { config.ACCESS_IP = spn_allowip.getSelectedItem().toString(); } else if (spn_allowip.getSelectedItem().toString().equalsIgnoreCase("Source IP")) { config.ACCESS_IP = "0.0.0.0"; } else { config.ACCESS_IP = txt_allowIP.getText().toString(); } config.NICK_NAME = txt_NickName.getText().toString(); config.SERVER_IP = txt_server_ip.getText().toString(); config.SERVER_PORT = txt_server_port.getText().toString(); config.SSH_CMD = ""; if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("SSH Uri")) { config.SSH_CMD = txt_ssh_cmd.getText().toString(); config.juice_uuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); } else if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("Juicessh")) { config.SSH_CMD = "juice:" + juice_adapt.getConnectionName(spn_juice.getSelectedItemPosition()); config.juice_uuid = juice_adapt.getConnectionId(spn_juice.getSelectedItemPosition()); } else { config.juice_uuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); config.SSH_CMD = ""; } config.KEY = txt_KEY.getText().toString(); //key config.KEY_BASE64 = chkb64key.isChecked(); //is key b64 config.HMAC = txt_HMAC.getText().toString(); // hmac key config.HMAC_BASE64 = chkb64hmac.isChecked(); //is hmac base64 mydb.updateConfig(context, config); //this updates the list for one panel mode Activity activity = getActivity(); if (activity instanceof ConfigListActivity) { ConfigListActivity myactivity = (ConfigListActivity) activity; myactivity.onItemSaved(); } else { ConfigDetailActivity myactivity = (ConfigDetailActivity) activity; myactivity.onBackPressed(); } } } else { return false; } return super.onOptionsItemSelected(item); }
From source file:flex.android.magiccube.activity.ActivityBattleMode.java
public void SaveReplay() { // TODO Auto-generated method stub if (dbHelper == null) { dbHelper = new DBHelper(this); }// w ww. j a va 2s . c om dbHelper.create(TableName, TableContent); ContentValues values = new ContentValues(); values.put("cmdstrbefore", this.GetCmdStrBefore()); values.put("cmdstrafter", this.GetCmdStrAfter()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); String datestr = dateFormat.format(date); values.put("savetime", datestr); values.put("movetimes", this.GetMoveTimes()); dbHelper.insert(TableName, values); Toast toast; if (State == OnStateListener.WIN) { toast = Toast.makeText(getApplicationContext(), "" + datestr, Toast.LENGTH_LONG); } else { toast = Toast.makeText(getApplicationContext(), "" + datestr, Toast.LENGTH_LONG); } toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
/** * Updates the view associated to the activity after the finish of an * operation trying to remove a file./*from ww w . j av a 2s .c om*/ * * @param operation Removal operation performed. * @param result Result of the removal. */ private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) { dismissDialog(DIALOG_SHORT_WAIT); if (result.isSuccess()) { Toast msg = Toast.makeText(this, R.string.remove_success_msg, Toast.LENGTH_LONG); msg.show(); OCFile removedFile = operation.getFile(); getSecondFragment(); FileFragment second = getSecondFragment(); if (second != null && removedFile.equals(second.getFile())) { cleanSecondFragment(); } if (mStorageManager.getFileById(removedFile.getParentId()).equals(getCurrentDir())) { refeshListOfFilesFragment(); } } else { Toast msg = Toast.makeText(this, R.string.remove_fail_msg, Toast.LENGTH_LONG); msg.show(); if (result.isSslRecoverableException()) { mLastSslUntrustedServerResult = result; showDialog(DIALOG_SSL_VALIDATOR); } } }
From source file:reportsas.com.formulapp.Formulario.java
public void HabilitarParametros(Menu menu) { for (int i = 0; i < encuesta.getParametros().size(); i++) { switch (encuesta.getParametros().get(i).getIdParametro()) { // Captura GPS case 1:/* ww w.j av a2 s . c om*/ menu.getItem(2).setVisible(true); parametroGPS = new ParametrosRespuesta(1); manejador = (LocationManager) getSystemService(LOCATION_SERVICE); if (!manejador.isProviderEnabled(LocationManager.GPS_PROVIDER)) { AlertDialog alert = null; final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("El sistema GPS esta desactivado, Debe activarlo!").setCancelable(false) .setPositiveButton("Activar GPS", new DialogInterface.OnClickListener() { public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) { startActivity( new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }); alert = builder.create(); alert.show(); } Criteria criterio = new Criteria(); criterio.setCostAllowed(false); criterio.setAltitudeRequired(false); criterio.setAccuracy(Criteria.ACCURACY_FINE); proveedor = manejador.getBestProvider(criterio, true); Location localizacion = manejador.getLastKnownLocation(proveedor); capturarLocalizacion(localizacion); manejador.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30000, 0, this); Toast toast1; if (parametroGPS.getValor().equals("Posicion Desconocida")) { toast1 = Toast.makeText(this, "Posicion Desconocida.", Toast.LENGTH_SHORT); } else { toast1 = Toast.makeText(this, "Localizacin obtenida exitosamente.", Toast.LENGTH_SHORT); } toast1.show(); break; // Captura Imgen case 2: menu.getItem(0).setVisible(true); break; // Lectura de Codigo case 3: menu.getItem(1).setVisible(true); break; default: break; } } }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) {/*from w ww .j a va2 s . c o m*/ dismissDialog(DIALOG_SHORT_WAIT); OCFile syncedFile = operation.getLocalFile(); if (!result.isSuccess()) { if (result.getCode() == ResultCode.SYNC_CONFLICT) { Intent i = new Intent(this, ConflictsResolveActivity.class); i.putExtra(ConflictsResolveActivity.EXTRA_FILE, syncedFile); i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, getAccount()); startActivity(i); } else { Toast msg = Toast.makeText(this, R.string.sync_file_fail_msg, Toast.LENGTH_LONG); msg.show(); } } else { if (operation.transferWasRequested()) { refeshListOfFilesFragment(); onTransferStateChanged(syncedFile, true, true); } else { Toast msg = Toast.makeText(this, R.string.sync_file_nothing_to_do_msg, Toast.LENGTH_LONG); msg.show(); } } }