void ImagePicker(int targetImage, int aspectX, int aspectY, int outputX, int outputY) {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", aspectX);
intent.putExtra("aspectY", aspectY);
intent.putExtra("outputX", outputX);
intent.putExtra("outputY", outputY);
intent.putExtra("scale", true);
intent.putExtra("scaleUpIfNeeded", true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, "image");
intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
try {
intent.putExtra("return-data", true);
startActivityForResult(Intent.createChooser(intent, "Complete action using"), targetImage);
} catch (ActivityNotFoundException e) {
appendToUI("App error");
}
}
This does not work on Lollipop, but works on KitKat!
I'm trying to call this method to allow user to select a picture from device and provide a Crop feature and once user selects "Save", Cropped picture is assigned to an ImageView.
Is there a generic way of doing this for JellyBean, KitKat and Lollipop. I still need the Crop feature!
Need help
Aucun commentaire:
Enregistrer un commentaire