title: Camera is not saving after taking image
body: <p>Camera is not saving after taking image in Redmi 1s. <strong>This works great in samsung j5-2016</strong>. I am trying to take picture and upload on server. Before uploading i am compressing image, so i need filename and file path. How I get <strong>fileName</strong> is displays in activity result method.</p>
  
  <p><strong>Camera Intent</strong></p>
  
  <pre><code>val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                          if (takePictureIntent.resolveActivity(activity.packageManager) != null) {
                              startActivityForResult(takePictureIntent, 102)
                          }
  </code></pre>
  
  <p>In samsung phone this saves picture, thus i am able to get file from uri. But in redmi 1s i am not able to get uri. I think it seems like redmi 1s not saving taken picture, therefore i am not able to get file.
  <strong>OnActivityResult in fragments displays as:</strong></p>
  
  <pre><code>override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
          super.onActivityResult(requestCode, resultCode, data)
          if (requestCode == 102) &amp;&amp; resultCode == Activity.RESULT_OK &amp;&amp; data != null) {
          val uri = data.data
  
                  val mimeType = activity.contentResolver.getType(uri)
                  if (mimeType == null) {
                      val path = getPath(uri)
                      if (path == null) {
                          fileName = FilenameUtils.getName(uri.toString())
                      } else {
                          val file = File(path)
                          fileName = file.getName()
                      }
                  } else {
                      val returnUri = data.getData()
                      val returnCursor = activity.contentResolver.query(returnUri, null, null, null, null)
                      val nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
                      val sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE)
                      returnCursor.moveToFirst()
                      fileName = returnCursor.getString(nameIndex)
                      val size = Long.toString(returnCursor.getLong(sizeIndex));
                  }
  }
      }
  </code></pre>
  
  <p>I am getting <strong>error</strong> in </p>
  
  <pre><code>val mimeType = activity.contentResolver.getType(uri)
  </code></pre>
  
  <p><strong>ErrorLog</strong></p>
  
  <pre><code>08-23 17:17:52.039 12008-12008/? W/System.err: java.lang.NullPointerException
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.content.ContentResolver.acquireExistingProvider(ContentResolver.java:1405)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.content.ContentResolver.getType(ContentResolver.java:304)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at in.motiontech.wave.fragment.ReviewOrderFragment.onActivityResult(ReviewOrderFragment.kt:396)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:164)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.app.Activity.dispatchActivityResult(Activity.java:5434)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.app.ActivityThread.deliverResults(ActivityThread.java:3363)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3410)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.app.ActivityThread.access$1300(ActivityThread.java:141)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1260)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
  08-23 17:17:52.039 12008-12008/? W/System.err:     at android.os.Looper.loop(Looper.java:136)
  08-23 17:17:52.049 12008-12008/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5052)
  08-23 17:17:52.049 12008-12008/? W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
  08-23 17:17:52.049 12008-12008/? W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
  08-23 17:17:52.049 12008-12008/? W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
  08-23 17:17:52.049 12008-12008/? W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
  08-23 17:17:52.049 12008-12008/? W/System.err:     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Help me if I am doing anything wrong please suggest other option.</p>
  
  <p>I have also looked some Stackoverflow posts but not able to find answer : </p>
  
  <p><a href="https://stackoverflow.com/questions/7720383/camera-intent-not-saving-photo">Camera Intent not saving photo</a></p>
  
  <p><a href="https://stackoverflow.com/questions/26224011/camera-is-not-saving-after-taking-picture">Camera is not saving after taking picture</a></p>
  
  <p><a href="https://stackoverflow.com/questions/27618074/can-not-save-cameras-captured-photo-in-applications-files-folder">Can not save camera&#39;s captured photo in application&#39;s &quot;files&quot; folder</a></p>
  
  <p><strong>Edit</strong>
  I have also tried following for <strong>Camera Intent</strong></p>
  
  <pre><code>val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                          val dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
                          var output = File(dir, System.currentTimeMillis().toString() + ".jpeg")
                          if (takePictureIntent.resolveActivity(activity.packageManager) != null) {
                              takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, output)
                              startActivityForResult(takePictureIntent, 102)
                          }
  </code></pre>