2019独角兽企业重金招聘Python工程师标准>>>
问题代码:
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.setType("image/*");
cropIntent.putExtra("crop", "true");
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
cropIntent.putExtra("outputX", Conf.getInt("IMAGE_WIDTH"));
cropIntent.putExtra("outputY", Conf.getInt("IMAGE_HEIGHT"));
cropIntent.putExtras(extras);
startActivityForResult(cropIntent, CROP_REQUEST_CODE);
这是4.3以前用的方法,那自从升级到4.4以后,该如何使用呢?
try {
int aspectX = 750;
int aspectY = 1011;
Intent intent = new Intent(this, CropImage.class);
intent.putExtra(CropImage.IMAGE_PATH, path);
intent.putExtra(CropImage.SCALE, true);
intent.putExtra("aspectX", aspectX);
intent.putExtra("aspectY", aspectY);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mCurrentPhotoPath)));
startActivityForResult(intent, CROP);
}catch (ActivityNotFoundException anfe) {
String errorMessage = "Your device doesn't support the crop action!";
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}