2

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 ?

Khairil Ushan
  • 2,358
  • 5
  • 26
  • 29
  • Check these questions: http://stackoverflow.com/questions/11591825/how-to-get-image-path-just-captured-from-camera http://stackoverflow.com/questions/15322670/how-to-get-image-path-from-camera-intent http://stackoverflow.com/questions/15432592/get-path-of-image-on-android http://stackoverflow.com/questions/7636697/get-path-and-filename-from-camera-intent-result – akuzma Aug 12 '13 at 09:27

2 Answers2

5

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

kalyan pvs
  • 14,486
  • 4
  • 41
  • 59
0

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
Prakash Jackson
  • 435
  • 6
  • 10