by this way
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, REQUEST_CODE);
i get a bitmap form intent in the onActivityResult, and not the path !, by this way
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
startActivityForResult(intent, REQUEST_CODE);
i can get the path from intent, and not the bitmap !!, how can i get the bitmap(thumbnail) and the path from android camera ?
From that you can get the image path with using that path create a thumbnail image like this
/**
*
* Returns the given size of the bitmap
*
* @param path
* @return {@link Bitmap}
*/
private Bitmap getThumbnailBitmap(String path, int thumbnailSize) {
BitmapFactory.Options bounds = new BitmapFactory.Options();
bounds.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, bounds);
if ((bounds.outWidth == -1) || (bounds.outHeight == -1)) {
return null;
}
int originalSize = (bounds.outHeight > bounds.outWidth) ? bounds.outHeight
: bounds.outWidth;
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = originalSize / thumbnailSize;
return BitmapFactory.decodeFile(path, opts);
}
give the size how much you want
Try this code, I've used this in an app and this will work perfect,
static final int CAMERA_REQUEST = 1888;
String name = dateToString(new Date(),"yyyy-MM-dd-hh-mm-ss");
File destination = new File(Environment.getExternalStorageDirectory(), name + ".jpg");
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
destination = new File(Environment.getExternalStorageDirectory(), name + ".jpg");
startActivityForResult(cameraIntent, CAMERA_REQUEST);
In your OnActivityResult()
Bundle bundle = data.getExtras();
if(bundle != null){
if (requestCode == CAMERA_REQUEST) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
//Here photo is your bitmap image, use this as per your requirement
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.