I am building an application that uses camera to take pictures. Here is my source code to do this:
File file = new File(Environment.getExternalStorageDirectory(),
imageFileName);
imageFilePath = file.getPath();
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
//Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intent, ACTIVITY_NATIVE_CAMERA_AQUIRE);
On onActivityResult()
method, I use BitmapFactory.decodeStream()
to pickup the image.
When I run my application on Nexus one, it runs well. But when I run on Samsung Galaxy S or HTC Inspire 4G, the image's direction is not correct.
Image preview after shot --------- Real image on SD card
Image preview after shot --------- Real image on SD card
There are quite a few similar topics and issues around here. Since you're not writing your own camera, I think it boils down to this:
some devices rotate the image before saving it, while others simply add the orientation tag in the photo's exif data.
I'd recommend checking the photo's exif data and looking particularly for
ExifInterface exif = new ExifInterface(SourceFileName); //Since API Level 5
String exifOrientation = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
Since the photo is displaying correctly in your app, i'm not sure where the problem is, but this should definitely set you on the right path!