我希望能够用相机拍照。我这样做并且有效:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intent, CAMERA_REQUEST);
成功后,我希望用户能够立即查看图像并能够裁剪。
我可以这样做:
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.setDataAndType(Uri.fromFile(new File(file.toString())), "image/*");
cropIntent.putExtra("crop", "true");
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
cropIntent.putExtra("outputX", 256);
cropIntent.putExtra("outputY", 256);
cropIntent.putExtra("return-data", true);
startActivityForResult(cropIntent, CAMERA_REQUEST);
如何合并这两个任务,使它们一个接一个地发生?我必须有两个startActivityForResult
吗?应该合并吗?或者裁剪 ginfo 应该在正常范围内吗?
getActivity();
if (requestCode == CAMERA_REQUEST && resultCode == Activity.RESULT_OK) {
// Cropping code here? another intent?
iPP.setImageBitmap(BitmapFactory.decodeFile(file.toString()));
imagePath = file.toString();
scaleImage();
new UploadImage().execute();
}