Save the wallpaper of an Android device as a picture

I need to write a program that gets the current wallpaper of an android device and save it to the images folder.

The problem is that I cannot find any information on how to convert the Drawable to a JPEG/PNG

This is my code:

android.graphics.drawable.Drawable currentWallpaper = getWallpaper();

How do I convert this Drawable into a JPEG/PNG file?

Answer

As previously mentioned here, take a look at http://www.brighthub.com/mobile/google-android/articles/30676.aspx. This discusses basically rendering your Drawable on a Canvas backed by a bitmap. You can then save the Bitmap to file using Bitmap.compress.

Leave a Reply

Your email address will not be published. Required fields are marked *