I am trying to make an image keyboard with the Android Commit Content API. In order to implement this, I need be able to store .png
and .gif
files on the device and create file objects from them.
Currently, I am using the Glide library to fetch images from the internet. An example image I might fetch is this. The Glide library provides me with drawables
that contain animated GIFs. I need to be able to encode these drawables into .gif
files that can be saved as files on the user's phone.
How can I do this?
I've looked at existing posts, such as this: How to convert a Drawable to a Bitmap?, but they aren't helpful because the Bitmap
object cannot store animated GIFs.
This post: saving gif file from drawable into phone sd? and remove it from sd after usage also seems relevant, but, it doesn't explain how to turn an animated Drawable
object into a list of Bitmap
objects.
Also, it doesn't explain how to save a series of Bitmap
objects as 1 GIF file.