android - Returning Imageuri=null (but data extras) from camera capture -


while debugging below code, getting value of picuri null , can see picuri=null data:"intent" {act=inline-data (has extras)}" in trace. why picuri not having corresponding uri , have data extras?

public void onclick(view v) {         if (v.getid() == r.id.capture_btn) {             try {                 // use standard intent capture image                 intent captureintent = new intent(                         mediastore.action_image_capture);                 // handle returned data in onactivityresult                 startactivityforresult(captureintent, camera_capture);             } catch (activitynotfoundexception anfe) {                 toast toast = toast.maketext(this, "this device doesn't support crop action!",                         toast.length_short);                 toast.show();             }         }     }      protected void onactivityresult(int requestcode, int resultcode, intent data) {         if (resultcode == result_ok) {             if (requestcode == camera_capture) {                 // uri captured image                 picuri = data.getdata();                                         }                  } } 

  1. here pass camera intent

    private void intentcamera() { intent cameraintent = new intent(mediastore.action_image_capture); startactivityforresult(cameraintent, camera_request); } 

  1. and after captured image

protected void onactivityresult(int requestcode, int resultcode, intent data) {   if (requestcode == camera_request && resultcode == result_ok) {     bitmap photo = (bitmap) data.getextras().get("data");      imageview.setimagebitmap(photo);     knop.setvisibility(button.visible);       // call method uri bitmap     uri tempuri = getimageuri(getapplicationcontext(), photo);      // call method actual path     file finalfile = new file(getrealpathfromuri(tempuri));      log.e("resultcapturedimage-->",mimagecaptureuri); }    }  public uri getimageuri(context incontext, bitmap inimage) { bytearrayoutputstream bytes = new bytearrayoutputstream(); inimage.compress(bitmap.compressformat.jpeg, 100, bytes); string path = images.media.insertimage(incontext.getcontentresolver(),  inimage, "title", null); return uri.parse(path); }  public string getrealpathfromuri(uri uri) { cursor cursor = getcontentresolver().query(uri, null, null, null, null);  cursor.movetofirst();  int idx = cursor.getcolumnindex(mediastore.images.imagecolumns.data);  return cursor.getstring(idx);  } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -