views:

60

answers:

1

Hello all,

I'm writing a live wallpaper and need some help. My wallpaper will create an effect over top of another image or existing wallpaper (not another live wallpaper) that the user chooses in the "Settings...".

My problem is this: I can't find a way to list the static wallpapers or images on the phone. I've seen some examples of getting the camera images, but not the wallpapers.

Any help would be appreciated.

A: 

If this helps, here's a FileFilter I wrote that will return a list of folders that contain images. You simply take a File representing a directory (I use it for Environment.getExternalStorageDirectory()) use .listFiles(filterForImageFolders) and it will return a File[] with the directories that contain images. You can then use this list to populate your list of images in your settings:

FileFilter filterForImageFolders = new FileFilter()
    {           
        public boolean accept(File folder)
        {
            try
            {
                //Checking only directories, since we are checking for files within
                //a directory
                if(folder.isDirectory())
                {
                    File[] listOfFiles = folder.listFiles();

                    if (listOfFiles == null) return false;

                    //For each file in the directory...
                    for (File file : listOfFiles)
                    {                           
                        //Check if the extension is one of the supported filetypes                          
                        for (String ext : imageExtensions)
                        {
                            if (file.getName().endsWith("." + ext)) return true;
                        }
                    }                       
                }
                return false;
            }
            catch (SecurityException e)
            {
                Log.v("debug", "Access Denied");
                return false;
            }
        }
    };

(ImageExtensions is a String[] containing "png", "bmp", "jpg", "jpeg")

kcoppock
Thanks. I'll see if I can use it to help. It doesn't give me what I want but I may be able to use it.
DarthNoodles
So are you looking for just the specific stock wallpapers?
kcoppock