android - How can I get the image path of an image taken with the camera? -


in app can click on image view gives option chose image sd card or take new picture camera. implemented option chose image sd card. left camera option.

my question: how can image path of new image taken camera?

below find code use open the dialog window , way path of images sd card.

1.this code dialog:

private void showimagedialog() {     final string [] items = new string [] {"from camera", "from sd card"};     arrayadapter<string> adapter = new arrayadapter<string> (this, android.r.layout.select_dialog_item,items);     alertdialog.builder builder = new alertdialog.builder(this);      builder.settitle("select image");     builder.setadapter( adapter, new dialoginterface.onclicklistener() {         public void onclick( dialoginterface dialog, int item ) {             if (item == 0) {                 intent intent = new intent(mediastore.action_image_capture);                 file file = new file(environment.getexternalstoragedirectory(),                                     "tmp_avatar_" + string.valueof(system.currenttimemillis()) + ".jpg");                 mimagecaptureuri = uri.fromfile(file);                  try {                     intent.putextra(android.provider.mediastore.extra_output, mimagecaptureuri);                     intent.putextra("return-data", true);                      startactivityforresult(intent, pick_from_camera);                 } catch (exception e) {                     e.printstacktrace();                 }                  dialog.cancel();             } else {                 intent intent = new intent();                  intent.settype("image/*");                 intent.setaction(intent.action_get_content);                  startactivityforresult(intent.createchooser(intent, "complete action using"), pick_from_file);             }         }     } );      final alertdialog dialog = builder.create();     dialog.show(); } 

2.and use image path sd card image.

@override public void onactivityresult(int requestcode, int resultcode, intent data) {     if (resultcode == result_ok) {         if (requestcode == pick_from_file || requestcode == pick_from_camera) {             uri selectedimageuri = data.getdata();             selectedimagepath = getpath(selectedimageuri);              log.v("image path====>>>> ",selectedimagepath);              // decode, scale , set image.             bitmap mybitmap = bitmapfactory.decodefile(selectedimagepath);             bitmap scaledbitmap = bitmap.createscaledbitmap(mybitmap, new_width, new_height, true);             mybitmap.recycle();             mybitmap = null;              mimageview.setimagebitmap(scaledbitmap);             mimageview.settag(selectedimagepath);         }       } } 


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -