我正在开发Android应用程序,我想从库中传递图像。以前我的代码从drawable获取图像并将其发送到cropping类。现在我想使用我选择的画廊图片而不是R.id.cropImg。
我的带有URI的图库图片代码如下:
// 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.