Get camera capture image path in android
calling camera
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);startActivityForResult(Intent.createChooser(cameraIntent,"Select Picture"), CAMERA_PIC_REQUEST1);
on result activity
final ContentResolver cr = getContentResolver();
final String[] p1 = new String[] {
MediaStore.Images.ImageColumns._ID,
MediaStore.Images.ImageColumns.DATE_TAKEN
}; Cursor c1 = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, p1, null, null, p1[1] + " DESC");
if ( c1.moveToFirst() ) {
String uristringpic = "content://media/external/images/media/" +c1.getInt(0);
Uri newuri = Uri.parse(uristringpic);
Log.i("TAG", "newuri "+newuri);
}
c1.close();
}
then u can
get Uri path capture image
This comment has been removed by the author.
ReplyDeleteThe best way to get image uri
ReplyDeleteThanks a lot!!!!!!!!!!!
ReplyDeletethe this is..dude..it returns the uri of a random pic from the camera folder..not the one i've taken which also i can't find it anywhere..so i suppose it doesn't get saved.. :(
ReplyDeleteThe callback onActivityResult gives an Intent too
ReplyDeleteEg: public void onActivityResult(int responseCode, Intent data)
The data contains the url
Just do a data.getData().toString()
You need not access the camera content resolver
The callback onActivityResult gives an Intent too
ReplyDeleteEg: public void onActivityResult(int responseCode, Intent data)
The data contains the url
Just do a data.getData().toString()
You need not access the camera content resolver
Dear aasha,
Deletethe code you posted does not work on many Samsung devices I've tested. For instance on a galaxy S3 (SGH-T999, android 4.1.1.).
"data" comes back as NULL - so your code throws an exception.
We are forced to use content resolvers or managed cursors.
This is a known problem, posted in many places, e.g. StackOverflow, and the link below, which is a good example of how clunky and difficult it is to use samsung devices as you all progressively break the android APIs. ( Not to mention webkit, nor the overall corporate plan of making your own OS and dropping android. I hope you all learn how bad an idea that will be.)
http://kevinpotgieter.wordpress.com/2011/03/30/null-intent-passed-back-on-samsung-galaxy-tab/ That link refers to the blog you are reading now.