Android: Activity getting Destroyed after calling Camera Intent

i had the same problem.i will be crazy but finally i have found a solution here. the issue is that when you click on “save” button of the camera the activity call change orientation method and it will destroy and recreated. try to set android:configChanges=”orientation|screenSize” in android manifest (not only android:configChanges=”orientation” because as suggest here, … Read more

Get Path of image from ACTION_IMAGE_CAPTURE Intent

This is how it works on 2.2 (different than on previous versions). When starting intent String fileName = “temp.jpg”; ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, fileName); mCapturedImageURI = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI); startActivityForResult(intent, CAPTURE_PICTURE_INTENT); you need to remember mCapturedImageURI. When you capture image, in onActivityResult() use that URI to obtain … Read more

Android startCamera gives me null Intent and … does it destroy my global variable?

It’s possible that launching of ACTION_IMAGE_CAPTURE will push your activity out of memory. You should check (I’d simply a log, debugger may have its own side effects) that onCreate() of your activity is called before onActivityResult(). If this is the case, you should prepare your activity to reinitialize itself, probably using onSaveInstanceState(Bundle). Note that the … Read more

How to capture an image and store it with the native Android Camera

Here was the final product in case anyone is still visiting this thread: public class CameraCapture extends Activity { protected boolean _taken = true; File sdImageMainDirectory; protected static final String PHOTO_TAKEN = “photo_taken”; @Override public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); File root = new File(Environment .getExternalStorageDirectory() + File.separator + “myDir” + File.separator); root.mkdirs(); … Read more

Android ACTION_IMAGE_CAPTURE Intent

this is a well documented bug in some versions of android. that is, on google experience builds of android, image capture doesn’t work as documented. what i’ve generally used is something like this in a utilities class. public boolean hasImageCaptureBug() { // list of known devices that have the bug ArrayList<String> devices = new ArrayList<String>(); … Read more

Low picture/image quality when capture from camera

I have used the following code and this works perfectly fine for me. values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, “New Picture”); values.put(MediaStore.Images.Media.DESCRIPTION, “From your Camera”); imageUri = getContentResolver().insert( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, PICTURE_RESULT); and also protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PICTURE_RESULT: if … Read more

Android camera intent

private static final int TAKE_PICTURE = 1; private Uri imageUri; public void takePhoto(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File photo = new File(Environment.getExternalStorageDirectory(), “Pic.jpg”); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); imageUri = Uri.fromFile(photo); startActivityForResult(intent, TAKE_PICTURE); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case TAKE_PICTURE: if (resultCode == … Read more

Why does an image captured using camera intent gets rotated on some devices on Android?

Most phone cameras are landscape, meaning if you take the photo in portrait, the resulting photos will be rotated 90 degrees. In this case, the camera software should populate the Exif data with the orientation that the photo should be viewed in. Note that the below solution depends on the camera software/device manufacturer populating the … Read more