title: Pick an Image and set it as a button's background drawable not working - Kotlin
body: <p>I am using android studio bumblebee and using kotlin:
  I want to upload a picture and set in the background of a button. below code does not work. pls someone help. Thanks</p>
  <pre><code>var selectedPhotoUri: Uri? = null
  
  override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
      super.onActivityResult(requestCode, resultCode, data)
  
      if (requestCode == 0 &amp;&amp; resultCode == Activity.RESULT_OK &amp;&amp; data != null) {
          Log.d(&quot;MainActivity&quot;, &quot;Photo was selected&quot;)
          selectedPhotoUri = data.data
          val bit = MediaStore.Images.Media.getBitmap(ContentResolver, selectedPhotoUri)
          val bitmapDrawable = BitmapDrawable(bit)
          val gtr = findViewById&lt;Button&gt;(R.id.select_photo_register)
          //gtr.setBackground(bitmapDrawable)
          gtr.setBackgroundDrawable(bitmapDrawable)
      }
  }
  </code></pre>