android - Get ID from Photo when saving -
in application, catch photo , save on mobile phone then.
this how that:
private void takepic() { contentvalues values = new contentvalues(); string title = null; values.put(mediacolumns.title, title); string description = null; values.put(imagecolumns.description, description); values.put(mediacolumns.mime_type, "image/jpeg"); imageuri = getcontentresolver().insert(mediastore.images.media.external_content_uri, values); intent intent = new intent(mediastore.action_image_capture); intent.putextra(mediastore.extra_output, imageuri); intent.putextra(mediastore.extra_video_quality, 1); startactivityforresult(intent, image_capture); }
my problem is, later want thumbnail of picture show thumbnail in listview. there way id of photo took , save intent
or this?
you can try quering mediastore.images.media.data
media uri have instead in mediastore content provider
protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if(resultcode==result_ok ){ if(requestcode == image_capture){ // media uri data uri media_uri = data.getdata(); string[] column = {mediastore.images.media._id}; cursor cursor = getcontentresolver().query(media_uri, column, null, null, null); cursor.movetofirst(); if(cursor.getcount()>0){ int media_id = cursor.getint(cursor .getcolumnindex(mediastore.mediacolumns._id)); //... store media id here.. } cursor.close(); } } }
Comments
Post a Comment