4

i can change home screen wallpaper but i can not change lock screen wallpaper,

                DisplayMetrics metrics = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(metrics);
                // get the height and width of screen
                int height = metrics.heightPixels;
                int width = metrics.widthPixels;

                WallpaperManager wallpaperManager = WallpaperManager
                        .getInstance(getApplicationContext());

                wallpaperManager.setBitmap(bitmap);


                wallpaperManager.suggestDesiredDimensions(width, height);

1 Answers1

7

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)
mikepenz
  • 12,708
  • 14
  • 77
  • 117