title: Can't parcel a recycled bitmap
body: <p>Currently I'm working on a music player app in which I create custom notification for controlling player and also use remotecontrolclient for background artwork at lock screen, on changes of track I update both notification and artwork. But on changing I get this error :</p>
  
  <pre><code>FATAL EXCEPTION: main Process: in.xyz.yst, PID: 19598
                   java.lang.IllegalStateException: Can't parcel a recycled bitmap
                   at android.graphics.Bitmap.checkRecycled(Bitmap.java:347)
                   at android.graphics.Bitmap.writeToParcel(Bitmap.java:1496)
                   at android.widget.RemoteViews$BitmapCache.writeBitmapsToParcel(RemoteViews.java:982)
                   at android.widget.RemoteViews.writeToParcel(RemoteViews.java:2707)
                   at android.widget.RemoteViews.clone(RemoteViews.java:1816)
                   at android.app.Notification.cloneInto(Notification.java:1474)
                   at android.app.Notification.clone(Notification.java:1448)
                   at android.app.NotificationManager.notify(NotificationManager.java:150)
                   at android.app.NotificationManager.notify(NotificationManager.java:124)
                   at in.catalystapp.catalyst.Artist.MusicPlayerService$setMediaplayer$1.onBitmapLoaded(MusicPlayerService.kt:292)
                   at com.squareup.picasso.TargetAction.complete(TargetAction.java:36)
                   at com.squareup.picasso.Picasso.deliverAction(Picasso.java:558)
                   at com.squareup.picasso.Picasso.complete(Picasso.java:510)
                   at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:117)
                   at android.os.Handler.dispatchMessage(Handler.java:102)
                   at android.os.Looper.loop(Looper.java:139)
                   at android.app.ActivityThread.main(ActivityThread.java:5298)
                   at java.lang.reflect.Method.invoke(Native Method)
                   at java.lang.reflect.Method.invoke(Method.java:372)
                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
  </code></pre>
  
  <p>My setupMediaplayer code is here :</p>
  
  <pre><code>mNotification.bigContentView.setImageViewResource(R.id.playpause, R.drawable.ic_pause_circle_outline_white_48dp)
      mNotification.contentView.setImageViewResource(R.id.playpause, R.drawable.ic_pause_circle_outline_white_48dp)
      mNotification.bigContentView.setTextViewText(R.id.track_title, mTrackItems.get(mCurrentposition).mTitle)
      mNotification.contentView.setTextViewText(R.id.track_title, mTrackItems.get(mCurrentposition).mTitle)
      mNotification.bigContentView.setTextViewText(R.id.track_label, mTrackItems.get(mCurrentposition).mLabel)
      mNotification.contentView.setTextViewText(R.id.track_label, mTrackItems.get(mCurrentposition).mLabel)
      Picasso.with(this).load(mTrackItems.get(mCurrentposition).mArtwork).into(object : Target{
          override fun onBitmapLoaded(notibitmap: Bitmap?, from: Picasso.LoadedFrom?) {
              if (!notibitmap!!.isRecycled){
                  mBitmapImage = Bitmap.createBitmap(notibitmap)
                  try {
                      mNotification.bigContentView.setImageViewBitmap(R.id.art_work,notibitmap)
                      mNotification.contentView.setImageViewBitmap(R.id.art_work,notibitmap)
                      mNotificationManager.notify(SharedPref.FOREGROUNDNOTICE_ID,mNotification)
                      if (UtilsFunctions.currentVersionSupportLockScreenControls()){
                          updateRemoteControlClientMetadata(mBitmapImage!!)
                      }
                  } catch (el : IllegalStateException){                
                      Log.d(TAG,el.toString())
                      if (UtilsFunctions.currentVersionSupportLockScreenControls()){
                          updateRemoteControlClientMetadata(mBitmapImage!!)
                      }
                  }
              }
              Log.d(TAG,"setup media player bitmap.isRecycled(): "+notibitmap.isRecycled)
          }
          override fun onBitmapFailed(errorDrawable: Drawable?) {
          }
          override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
          }
      })
      isstart = false
      val mUrl : String = mTrackItems.get(mCurrentposition).mStreamUrl+soundcloud_clientid
      Log.d(TAG,"On Media player Setmediaplayer with stream "+mUrl)
      mMedaiPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC)
      try {
          mMedaiPlayer.setDataSource(mUrl)
          mMedaiPlayer.prepareAsync()
          mMedaiPlayer.setOnPreparedListener(this)
          mMedaiPlayer.setOnCompletionListener(this)
      } catch (el : IllegalStateException){
          Log.d(TAG,"Illegalstate Exception"+el.toString())
          mMedaiPlayer.reset()
      } catch (ei : IOException){
          Log.d(TAG,"IO Exception"+ei.toString())
          mMedaiPlayer.reset()
      } catch (e : Exception){
          Log.d(TAG,"Exception"+e.toString())
          mMedaiPlayer.reset()
      }
  </code></pre>
  
  <p>Code for updating remotecontrolclient is here : </p>
  
  <pre><code>if (myRemoteControlClient != null) {
          val editor = myRemoteControlClient!!.editMetadata(true)
          editor.putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK,mBitmapImage)
          editor.apply()
          Log.d(TAG,"after update remote bitmap.isRecycled(): "+editor.getBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK,mBitmapImage).isRecycled)
      }
  </code></pre>
  
  <p>I read some post on stackoverflow which gives reason that my bitmap is recycled by remotecontrolclient, but I keep the track of bitmap is recycled or not, all logs show false means my bitmap is not recycled. Where I'm doing wrong and how to solve this problem</p>