-1

I want to change the lockscreen wallpaper of Android. I was able to change home screen wallpaper through WallpaperManager.setResource

But I am unable to set LockScreen Wallpaper

Also is there any way to change it over time automatically?

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

0

As of the latest Android API 24 it is possible to update the Lockscreen wallpaper by using the WallpaperManager and providing the FLAG_LOCK flag.

wallpaperManager.setBitmap(bitmap, null, true, WallpaperManager.FLAG_LOCK)

check this question for more details.

How can change lockscreen wallpaper in android with code?

nkalra0123
  • 2,281
  • 16
  • 17
0

Frist Create Bitmap source from drawable Resource

Bitmap icon = BitmapFactory.decodeResource(getViewContext().getResources(), R.drawable.wall);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        WallpaperManager wallpaperManager =WallpaperManager.getInstance(getViewContext());
        try {
            wallpaperManager.setBitmap(icon, null, true, WallpaperManager.FLAG_LOCK);
        } catch (IOException e) {
            e.printStackTrace();
        }
    
MohammadReza
  • 154
  • 1
  • 11