我想获取使用我的应用拍摄的照片缩略图。但我没有使用以下代码获取它。请帮忙。 这是代码:
Intent i = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
File file = new
File(Environment.getExternalStorageDirectory(), "MyImages");
file.mkdirs();
File image = new File(file, "picture1" + ".png");
Uri uriSavedImage = Uri.fromFile(image);
i.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
final int THUMBSIZE = 64;
Bitmap ThumbImage = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(image.getPath()),
THUMBSIZE, THUMBSIZE);
startActivity(i);
答案 0 :(得分:0)
首先
static final int REQUEST_IMAGE_CAPTURE = 1;
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
然后
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
mImageView.setImageBitmap(imageBitmap);
}
}
有关详情,请参阅官方指南https://developer.android.com/training/camera/photobasics.html