android - Image sd card path from intent gallery -
i starting gallery through intent otherwise giving problem display gallery in grid view. want actual sd card path of image selection gallery, opened intent.
here code..
intent photopickerintent = new intent(intent.action_get_content); photopickerintent.settype("image/jpg"); photopickerintent.putextra(intent.extra_stream, uri.parse("file:///sdcard/pictures/image.jpg")); startactivityforresult(photopickerintent, 1); protected void onactivityresult(int requestcode, int resultcode, intent intent) { super.onactivityresult(requestcode, resultcode, intent); if (resultcode == result_canceled) { showtoast(this,"activity cancelled"); return; } else if(resultcode == result_ok) { system.out.println("requestcode--"+requestcode); system.out.println("resultcode--"+resultcode); system.out.println("data--"+intent.getdata()); uri uri = intent.getdata(); string data = uri.getpath(); system.out.println("uri.getpath()--"+uri.getpath()); system.out.println("type--"+intent.gettype()); system.out.println("path--"+environment.getexternalstoragestate()); return; } switch (requestcode) { case camera_activity: bundle b = intent.getextras(); bitmap bm = (bitmap) b.get("data"); // mimageview.setimagebitmap(bm); // display image in view // large image? if (b.containskey(mediastore.extra_output)) { // large image? log.i(tag, "this large image"); showtoast(this,"large image"); // should have nothing big images -- should saved in mediastore ... mediastore.images.media.insertimage(getcontentresolver(), bm, null, null); } else { log.i(tag, "this small image"); showtoast(this,"small image"); mediastore.images.media.insertimage(getcontentresolver(), bm, null, null); } break; } } }
i getting data intent object. want sd card path image selecting upload image in server..
how that?
you may want this:
uri uri = (uri) intent.getextras().get("android.intent.extra.stream"); if ( intent.getaction().equals( intent.action_send ) ) { if ( uri.getscheme().equals("content")) { cursor cursor = getcontentresolver().query( uri, null, null, null, null ); cursor.movetofirst(); filepath = cursor.getstring(cursor.getcolumnindexorthrow(images.media.data)); } }
Comments
Post a Comment