title: OnActivityResult given null data from intent
body: <p>Im getting problem when I get image from gallery and put intent data as null. I have same code in other fragment where I register a user with foto and there is no problem there.
  <a href="https://i.stack.imgur.com/Ti3Hq.png" rel="nofollow noreferrer">This is profilefragment where the error happens</a></p>
  <pre><code>private fun loadImage() {
      /*val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
      startActivityForResult(intent, pickImage)*/
      val imageIntent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI)
      startActivityForResult(imageIntent, pickImage) //funciona*/
  
  }
  @Suppress(&quot;DEPRECATION&quot;)
  override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
      super.onActivityResult(requestCode, resultCode, data)
      if (resultCode == AppCompatActivity.RESULT_OK &amp;&amp; requestCode == pickImage) {
  
          if (data != null) {
              try {
                  val imageUri = data.data //data.extras!!.get(&quot;data&quot;) as Bitmap
                  val bitmap =
                      MediaStore.Images.Media.getBitmap(context?.contentResolver, imageUri)
                  avatar.setImageURI(imageUri)
                  register_avatarFilename.setText(&quot;image_test&quot;)
                  register_avatarFiledata.text = saveImage(bitmap)
              } catch (ioe: IOException) {
                  ioe.printStackTrace()
                  register_avatarFilename.setText(&quot;Image upload failed&quot;)
              }
          }
      }
  }
  
  fun saveImage(myBitmap: Bitmap): String {
      val bytes = ByteArrayOutputStream()
      myBitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes)
      val b = bytes.toByteArray()
      val encodedAvatar = Base64.encodeToString(b, Base64.DEFAULT)
      return encodedAvatar
  }
  </code></pre>