I am working on Android application in which I want to pass image from gallery. Previously my code take image from drawable and send it to cropping class. Now I want to use my gallery pic which I have selected instead of R.id.cropImg.
My code for gallery image with URI is also given below:
// for image gallery
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
// OnActivity
if (requestCode == SELECT_PICTURE) {
final Uri selectedImageUri = data.getData();
//showLoadingDialog();
if (Build.VERSION.SDK_INT < 19) {
selectedImagePath = getPath(selectedImageUri);
int index=1;
mIntent.putExtra("index", index);
startActivityForResult(mIntent, requestCode);
}
}
// now I want to give the location of my image in place
// of R.id.cropImg
setContentView(R.layout.fragment_cropimage);
final CropImageView mCropImage = (CropImageView)findViewById(R.id.cropImg);
mCropImage.setDrawable(getResources().getDrawable(R.drawable.precrop),300,300);
// Before galley it was taking img from drawable for
// cropping, now I want from gallery.