title: Android - can vector drawables store GIF files/animated images?
body: <p>I have made a custom keyboard that allows users to send GIFs/Images. </p>
  
  <p>Currently, whenever the user taps on a <code>ImageView</code>, the following code runs. It checks whether the drawable inside the <code>ImageView</code> is animated (i.e - the image is a <code>GifDrawable</code>) and if not, it casts it to a <code>BitmapDrawable</code>. <code>context.contentComitter.commit()</code> is responsible for turning the casted drawables into files that can be read by other apps. </p>
  
  <pre><code>        if(holder.imageView.drawable is GifDrawable) {
              context.contentCommitter.commitGifDrawable(holder.imageView.drawable, fileName)
          } else {
              context.contentCommitter.commitBitmapDrawable(holder.imageView.drawable as BitmapDrawable, fileName)
          }
  </code></pre>
  
  <p>The problem is - I'm getting the following crash for certain images on Samsung Galaxy S9s only:</p>
  
  <blockquote>
    <p>Fatal Exception: java.lang.ClassCastException
    android.graphics.drawable.VectorDrawable cannot be cast to android.graphics.drawable.BitmapDrawable</p>
  </blockquote>
  
  <p>The solution seems to be simple - just perform another check for whether <code>holder.imageView.drawable</code> is a <code>VectorDrawable</code>, and if so, extract the <code>Bitmap</code> and write it to a file. </p>
  
  <p>However, the problem is that the <code>VectorDrawable</code> source seems to be a GIF file, instead of a static image. This is confusing because the methods in the <code>VectorDrawable</code> documentation indicate that it is only used to store static images.</p>
  
  <p>Is it possible for a <code>VectorDrawable</code> to contain animated images (i.e - GIFs), or do <code>VectorDrawable</code>s only contain static images? </p>
  
  <p>Here is the image database: <a href="https://github.com/vedantroy/Image-Database" rel="nofollow noreferrer">https://github.com/vedantroy/Image-Database</a></p>