title: Wrong image name and type when saving bitmap Android 8
body: <p>I have a fun that saves bitmap as PNG or JPG (both not working), but seems like using content values not working as expected. </p>
  
  <ol>
  <li>File name is incorrect.</li>
  <li>File type is incorrect.</li>
  </ol>
  
  <p>What am I missing ?
  Works on Android 10, but not working on Android 8</p>
  
  <pre class="lang-kotlin prettyprint-override"><code>fun Bitmap.save(context: Context) {
      val contentResolver = context.contentResolver
  
      val contentValues = ContentValues().apply {
          put(MediaStore.MediaColumns.DISPLAY_NAME, "test.png")
          put(MediaStore.MediaColumns.TITLE, "test")
          put(MediaStore.MediaColumns.MIME_TYPE, "image/png")
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.Q) {
              put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_PICTURES)
              put(MediaStore.MediaColumns.IS_PENDING, 1)
          }
      }
  
      val contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
      val uri = contentResolver.insert(contentUri, contentValues)
      if (uri != null) {
          try {
              contentResolver.openFileDescriptor(uri, "w", null)?.use {
                  if (it.fileDescriptor != null) {
                      with(FileOutputStream(it.fileDescriptor)) {
                          compress(
                              Bitmap.CompressFormat.PNG,
                              DEFAULT_IMAGE_QUALITY,
                              this
                          )
                          flush()
                          close()
                      }
                  }
              }
          } catch (e: Exception) {
              e.printStackTrace()
          }
  
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.Q) {
              contentValues.clear()
              contentValues.put(MediaStore.MediaColumns.IS_PENDING, 0)
              contentResolver.update(uri, contentValues, null, null)
          }
  
          MediaScannerConnection.scanFile(context, arrayOf(uri.toString()), null, null)
      }
      recycle()
  }
  </code></pre>
  
  <p>Actual file name is <strong>1592205828045</strong> (some timestamp)</p>
  
  <p>Actual file type is <strong>jpg</strong> with <strong>0B</strong> - as it was not saved properly ?</p>