List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.amansoni.tripbook.activity.AddItemActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { super.onActivityResult(requestCode, resultCode, imageReturnedIntent); switch (requestCode) { case SELECT_PHOTO: if (resultCode == RESULT_OK) { // try { final Uri imageUri = imageReturnedIntent.getData(); mImageFilePath = ImageWrapper.getRealPathFromURI(this, imageUri); ImageWrapper.loadImageFromFile(this, mMainImage, mImageFilePath, 400); if (mTripbookItem != null) { mTripbookItem.setThumbnail(mImageFilePath); }//from w w w .ja v a 2 s .c o m // final InputStream imageStream = getContentResolver().openInputStream(imageUri); // final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream); // mMainImage.setImageBitmap(selectedImage); // } catch (FileNotFoundException e) { // e.printStackTrace(); // } } } }
From source file:aerizostudios.com.cropshop.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if ((requestCode == REQUEST_PICTURE) && (resultCode == RESULT_OK)) { final Uri selectedImageUri = data.getData(); //Bitmap imgbitmap = (new UserPicture(selectedImageUri, getContentResolver()).getBitmap()); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) { Blurry.with(MainActivity.this).radius(25).sampling(2) .onto((RelativeLayout) findViewById(R.id.tobe)); }//from w w w . j a v a 2 s . co m Glide.with(getApplicationContext()).load(selectedImageUri).asBitmap() .into(new SimpleTarget<Bitmap>(quality, quality) {//defines quality 100 low 400 high nearby 1060 @Override public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) { Send(resource); } });//passing intent through bitmap } }
From source file:io.v.android.apps.syncslides.DeckChooserFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_IMPORT_DECK: if (resultCode != Activity.RESULT_OK) { String errorStr = data != null && data.hasExtra(DocumentsContract.EXTRA_ERROR) ? data.getStringExtra(DocumentsContract.EXTRA_ERROR) : ""; toast("Error selecting deck to import " + errorStr); break; }//from w w w . j a va 2 s .c o m Uri uri = data.getData(); importDeck(DocumentFile.fromTreeUri(getContext(), uri)); break; } }
From source file:com.google.cloud.solutions.smashpix.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { if (requestCode == Constants.TAKE_PICTURE) { new UploadImageTask(this).execute(); } else if (requestCode == Constants.SELECT_PICTURE) { if (data.getData().getPath().startsWith(PICASA_URI_PREFIX)) { new DownloadGooglePhotoTask(this).execute(data.getData()); } else {/*from ww w . j av a 2 s. co m*/ imageStoragePath = new File(getPathFromData(data.getData())); new UploadImageTask(this).execute(); } } } }
From source file:org.yaoha.YaohaActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == SELECT_PICTURE) { selectedImageUri = data.getData(); Bitmap tmpbitmap = null;/*from w w w . jav a2 s. co m*/ try { tmpbitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImageUri); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } int tmp_width = tmpbitmap.getWidth(); int tmp_height = tmpbitmap.getHeight(); Bitmap fav_bitmap = null; if (tmp_width < tmp_height) { fav_bitmap = Bitmap.createBitmap(tmpbitmap, 0, (tmp_height - tmp_width) / 2, tmp_width, tmp_width); } else if (tmp_height < tmp_width) { fav_bitmap = Bitmap.createBitmap(tmpbitmap, (tmp_width - tmp_height) / 2, 0, tmp_height, tmp_height); } else { fav_bitmap = tmpbitmap; } actualButton.setImageBitmap(Bitmap.createScaledBitmap(fav_bitmap, actualButton.getWidth() - 20, actualButton.getHeight() - 20, false)); if (actualButton.getId() == button_favorite_1.getId()) { writeDrawableToSD(actualButton.getDrawable(), "pic_fav_1.jpg"); } } } }
From source file:com.example.cake.mqtttest.registerActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { super.onActivityResult(requestCode, resultCode, imageReturnedIntent); switch (requestCode) { case SELECT_PHOTO: if (resultCode == RESULT_OK) { Uri selectedImage = imageReturnedIntent.getData(); InputStream imageStream = null; try { imageStream = getContentResolver().openInputStream(selectedImage); Bitmap yourSelectedImage = decodeUri(selectedImage); ImageView x = (ImageView) findViewById(R.id.avatarImageView); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); yourSelectedImage.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); x.setImageBitmap(yourSelectedImage); } catch (FileNotFoundException e) { e.printStackTrace();//from ww w . j av a 2s .c om } } } }
From source file:com.esri.arcgisruntime.sample.editfeatureattachments.EditAttachmentActivity.java
/** * Upload the selected image from the gallery as an attachment to the selected feature * * @param requestCode RESULT_LOAD_IMAGE request code to identify the requesting activity * @param resultCode activity result code * @param data Uri of the selected image */// w ww . j av a 2s .c o m @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); if (cursor != null && cursor.moveToFirst()) { int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String picturePath = cursor.getString(columnIndex); cursor.close(); // covert file to bytes to pass to ArcGISFeature byte[] imageByte = new byte[0]; try { File imageFile = new File(picturePath); imageByte = FileUtils.readFileToByteArray(imageFile); } catch (IOException e) { e.printStackTrace(); } final String attachmentName = getApplication().getString(R.string.attachment) + "_" + System.currentTimeMillis() + ".png"; progressDialog.setTitle(getApplication().getString(R.string.apply_edit_message)); progressDialog.setMessage(getApplication().getString(R.string.wait)); progressDialog.show(); ListenableFuture<Attachment> addResult = mSelectedArcGISFeature.addAttachmentAsync(imageByte, "image/png", attachmentName); addResult.addDoneListener(new Runnable() { @Override public void run() { final ListenableFuture<Void> tableResult = mServiceFeatureTable .updateFeatureAsync(mSelectedArcGISFeature); tableResult.addDoneListener(new Runnable() { @Override public void run() { applyServerEdits(); } }); } }); } } }
From source file:cn.com.caronwer.activity.CertificationActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Uri uri;// ww w .j a v a 2 s. c o m switch (requestCode) { case REQUESTCODE_PICK:// ? if (data == null) { return; } uri = data.getData(); if (uri != null) { startPhotoZoom(uri); } break; case REQUESTCODE_TAKE:// ? if (resultCode == RESULT_CANCELED) { return; } File temp = new File(Environment.getExternalStorageDirectory() + "/" + IMAGE_FILE_NAME); uri = Uri.fromFile(temp); System.out.println(uri); if (uri != null) { startPhotoZoom(uri); } break; case REQUESTCODE_CUTTING:// ??? if (data == null) { return; } else { setPicToView(data); } break; } super.onActivityResult(requestCode, resultCode, data); }
From source file:edu.cloud.iot.reception.ocr.FaceRecognitionActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 0) { Bitmap img = (Bitmap) data.getExtras().get("data"); imageResult.setImageBitmap(img); }/*w w w .j av a 2 s .co m*/ if (requestCode == SET_COMPARE_IMAGE && resultCode == RESULT_OK && null != data) { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String picturePath = cursor.getString(columnIndex); cursor.close(); Bitmap compImg = BitmapFactory.decodeFile(picturePath); ByteArrayOutputStream bos = new ByteArrayOutputStream(); compImg.compress(Bitmap.CompressFormat.JPEG, 100, bos); compareImageBytes = bos.toByteArray(); // ImageView imageView = (ImageView) findViewById(R.id.imgView); // imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath)); } }