android - Get Path of image from ACTION_IMAGE_CAPTURE Intent -


hi using action_image_capture capturing image using intent follows:

intent cameraintent = new intent(mediastore.action_image_capture); cameraintent.putextra( mediastore.extra_output, (new file(environment.getexternalstoragedirectory(), string.valueof(system.currenttimemillis()) + ".jpg")) ); startactivityforresult(cameraintent, 0); 

i need store image in sdcard , retrieve path of image using onactivityresult method. don't know how image path of captured image.

if 1 knows please help.

thanks

this how works on 2.2 (different 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 remember mcapturedimageuri.

when capture image, in onactivityresult() use uri obtain file path:

            string[] projection = { mediastore.images.media.data};              cursor cursor = managedquery(mcapturedimageuri, projection, null, null, null);              int column_index_data = cursor.getcolumnindexorthrow(mediastore.images.media.data);              cursor.movetofirst();              string capturedimagefilepath = cursor.getstring(column_index_data); 

update: on new android devices not need mediastore.extra_output, rather deduce image/video uri data.getdata() received onactivityresult(..., intent data), nicely described under

android action_image_capture intent

however, since part subject manufacturer adaptation, may still encounter phones "old" approach may useful.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -