1

I have found plenty of details on how to set a wallpaper from a drawable etc however is it possible to do this from a file location.

I have confirmed that the following code prints out the location of the file

Toast.makeText(MyWallpapers.this, "" + listFile[position].getAbsolutePath(), Toast.LENGTH_SHORT).show();

String ImageLocation = listFile[position].getAbsolutePath();

And so I have been trying something like this to get it to set the wallpaper.

WallpaperManager myWallpaperManager 
        = WallpaperManager.getInstance(getApplicationContext());
try {
    myWallpaperManager.setResource(ImageLocation);
} catch (IOException e) {
    e.printStackTrace();
}

But it doesn't like it.

Any advice?

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
Master Zangetsu
  • 262
  • 7
  • 20

1 Answers1

1

Load the file into a Bitmap using BitmapFactory and call WallpaperManager.setBitmap

jspurlock
  • 1,466
  • 10
  • 7