0

i was looking around if it's possible to set Wallpaper for Lockscreen directly from android Sdk but unfortunately it's not available yet but how ever i have seen some apps able to do that via Stock gallary app as in the picture is there a certain intent for gallary app to set A certain image as wallpaper ? Thanks

enter image description here

Joseph27
  • 129
  • 3
  • 16

1 Answers1

0

You can set a Bitmap as a wallpaper using the WallpaperManager. It defines a method setBitmap() which allows you to set the bitmap as wallpaper.

However, to do that, you need the permission to set the wallpaper to be defined in the manifest.

how can i send my bitmap to gallary
You need to create a file with appropriate extension and then use the compress() method to write it to that file.
Here is a quick code that I took from another answer on SO:

try {
       FileOutputStream out = new FileOutputStream(filename);
       bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
       e.printStackTrace();
}
An SO User
  • 24,612
  • 35
  • 133
  • 221
  • I'm aware that you can set wallpaper by using wallpaper manager but it only works for home screen so lets say i already got the path to my image and it has .jpg extension so how i can send that image path to gallery app to set it as lock/home screen.Thanks in advance – Joseph27 Aug 29 '13 at 03:02
  • You have a `Bitmap` that you want to store as a JPG, so set the constant in `compress()` to `Bitmap.CompressFormat.JPEG` – An SO User Aug 29 '13 at 04:48
  • You can set the lock screen image programatically but that is a security violation. You may want to have a look here : https://code.google.com/p/mylockforandroid/ More on that here: http://stackoverflow.com/questions/2653954/how-to-set-android-lock-screen-image – An SO User Aug 29 '13 at 04:52
  • And please note that `JPEG` are highly compressed images so if you have an image downloaded from the internet as a `Bitmap`, please do not expect a lot of compresion – An SO User Aug 29 '13 at 04:53