我的代码有问题。我想在我的app目录中创建一个文件夹,并希望保存到那里的捕获图像,并希望检索该图像的地址。我的代码适用于默认相机目录的一些手机。
这是我的代码。
camera.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, 0);
}
});
protected void onActivityResult(int requestCode, int resultCode, Intent resultData) {
super.onActivityResult(requestCode, resultCode, resultData);
image=(ImageView)findViewById(R.id.image);
FaceCropper mFaceCropper=new FaceCropper();
if (resultData != null) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToLast();
String imagePath = cursor.getString(column_index_data);
bitmapOrg = BitmapFactory.decodeFile(imagePath);
try{
ExifInterface exif = new ExifInterface(imagePath);
int rotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
int rotationInDegrees = exifToDegrees(rotation);
Matrix matrix = new Matrix();
if (rotation != 0f) {matrix.preRotate(rotationInDegrees);}
Bitmap adjustedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, bitmapOrg.getWidth(), bitmapOrg.getHeight(), matrix, true);
Bit_map=mFaceCropper.getCroppedImage(adjustedBitmap);
image.setVisibility(ImageView.VISIBLE);
image.setImageBitmap(Bit_map);
}catch (IOException e){
e.printStackTrace();
}
}
}