title: Can't get Uri from data.getData()
body: <p>I'm trying to capture image and upload it to <code>Firebase</code>.
  The problem is that i'm getting null from <code>data.getData()</code> in the <code>onActivityResult</code>.</p>
  
  <p>I looked to web and couldn't find anything that worked for me in this case.</p>
  
  <pre><code>public void onClick(View v) {
     Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
     startActivityForResult(intent,  CAMERA_REQUEST_CODE);
  }
  </code></pre>
  
  <p>this is the <code>onActivityResult</code>:</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  Uri uri = data.getData();
  StorageReference filePath = storageRef.child("labelPhoto").child(uri.getLastPathSegment())
  filePath.putFile(uri).addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
                  @Override
                  public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
  ....rest of the code... }
  </code></pre>
  
  <p>I can't send to uri since i get null on <code>data.geData()</code>;</p>
  
  <p>I tried a number of solutions, like saving the image as bmp and get this uri:</p>
  
  <pre><code>Bitmap bitmap= (Bitmap)data.getExtras().get("data");
              captureImage.setImageBitmap(bitmap);
  String mPath = Environment.getExternalStorageDirectory().toString() + "/Pictures/" + picName + ".jpg";
              File imageFile = new File(mPath);
              FileOutputStream outputStream = null;
  
  
              try {
                  outputStream = new FileOutputStream(imageFile);
                  bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
                  outputStream.flush();
                  outputStream.close();
                  String temp = Environment.getExternalStorageDirectory().getPath() + "/Pictures/";
                  uri=  Uri.fromFile(imageFile);
                  Log.d("TAG", uri.toString());
              } catch (FileNotFoundException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
                  java.net.URI javaUri = java.net.URI.create(uri.toString());
                  android.net.Uri androidUri = android.net.Uri.parse(uri.toString());
                  StorageReference filePath = storageRef.child("labelPhoto").child(androidUri.toString());
  filePath.putFile(uri).addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
  
                      @Override
                      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
  ....rest of the code...}
  </code></pre>
  
  <p>add checks like:</p>
  
  <pre><code>  if(resultCode != RESULT_CANCELED){
  </code></pre>
  
  <p>and </p>
  
  <pre><code>if(data!=null)
  </code></pre>
  
  <p>the manifest:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.CAMERA"/&gt;
  &lt;uses-feature android:name="android.hardware.camera" /&gt;
  </code></pre>
  
  <p>Without any success.
  Anyone has an idea?</p>