There is a built-in library http://jiggawatt.org/badc0de/android/index.html#gifflen for this
I wrote a small native library for Android to quantize the color (from 2-256 colors) of the bitmap and save the result as a frame in an animated GIF (you can add as many frames as you want). You can hack and demolish the library code as you would like. The color quantizer used is Anthony Dekker NeuQuant, with some changes made by me.
For java library try http://www.jappit.com/blog/2008/12/04/j2me-animated-gif-encoder/
The use is quite simple, and the following steps are required: Create an instance of an AnimatedGifEncoder object Run it by passing an OutputStream as an argument (for example: ByteArrayOutputStream) Add image objects using the addFrame () method Finish it by calling finish ()