I'm trying to follow this tutorial: http://mobile.tutsplus.com/tutorials/android/capture-and-crop-an-image-with-the-device-camera/
But, after taking the photo, when the picture is going to be cropped, appears, "loading image..." forever.
I've tried to Toast the "picUri = data.getData();" and it returned null. I've read that in some devices we need to specify filename for picture to be taken, so I tried, but no good results.
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, "file:///tmp/android.jpg");
startActivityForResult(captureIntent, CAMERA_CAPTURE);
I'm testing it in a Galaxy Nexus and a Galaxy 5.
Someone have any idea?
Thank you.
I think the file path you are providing to the EXTRA_OUTPUT is wrong. Instead try using something like this:
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
String storagePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmp/android.jpg";
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, storagePath);
startActivityForResult(captureIntent, CAMERA_CAPTURE);
Related
I would like to open just one image and have pitch-zoom function, so (as I think) easiest way to do that is to open that image in gallery intent. Anybody can share example of how to call gallery intent with particular picture from drawable?
I tried to used something like that but can't make it working (wrong file patch?).
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("com.me.example/drawable/thisimage.png"), "image/*");
startActivity(intent);
According to this post
You should do something like:
String uriStr = "android.resource://"+ "com.example.myapp"+ "/" + R.drawable.photo_h01;
Uri uri = Uri.parse(uriStr);
I have not Eclipse in front of me but that's what I have found on several sources
I have an app that a user will be able to take pictures with. Having the camera is a small, but necessary feature but I want it to only be able to take pictures (no video). Is there a way I can make it startIntentForResult with a pictures-only camera intent? Or perhaps make it only accept images as the result? Making my own custom camera for the app seems a bit overkill, but I will do it if I have to.
Thanks
This code has been working for me for ever
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Uri uri = Uri.fromFile(File.createTempFile("image", ".jpg"));
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(Intent.createChooser(cameraIntent, "Take Picture", 0);
in my app, using Gingerbread, this piece of code works:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAMERA);
But in ICS (I tried on different ROMs), using
Uri selectedImageUri = data.getData();
returns null.
How can I make the first code work?
Thanks in advance
.
PS: I found this solution:
File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(dir, "avatar.jpeg")));
But if a device haven't a storage expansion? Plus I dont need to save the image.
We are making an application and in it, we want the ability to save an image. It works great and saves the image automagically on my friends phone which is a samsung galaxy II. But on my Galaxy Nexus it just returns the bitmap data.
The problem is that we are using a function to get the last image path and since Galaxy Nexus won't save the file it just takes the last photo taken with the normal camera application.
This is our code before on result:
private void takePhoto() {
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
}
So what I want is the know-how to save the image on the sdcard so we can use it later.
The following code should tell the camera to save the image to /sdcard/file.jpg:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri mImageCaptureUri = Uri.fromFile(new File(Environment
.getExternalStorageDirectory(), "file.jpg"));
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
mImageCaptureUri);
intent.putExtra("return-data", true);
startActivityForResult(intent, 0);
I use the following code to take a picture:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path + "/" + fileName)));
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
Now when I use this, it does save the picture where I specify above, but it also saves a second copy to the default image folder and adds it to the gallery.
I would simply delete the second file, but it seems it would be a tad dangerous as onActivityResult's intent parameter is always null after taking said picture, so I would have to attempt deleting the most recently saved picture.
Is there any way I can prevent this behavior or correct it by getting the URI of the dupicate picture?
Well I've determined that it is pretty much not possible. I am now using a SurfaceView with my own camera activity.