Search code examples
androidkotlinsetwallpaper

Set lock screen wallpaper of Android device programmatically


There is bunch of wallpaper applications where you can change lock screen wallpaper separate from main wallpaper. If I am not mistaken from API 24 it is possible to do such kind of thing, but I find very few articles related to this besides they are TOO old.


Solution

  • WallpaperManager has a number of methods to help you get or set the specific wallpapers. As you want the lock screen wallpaper, use FLAG_LOCK. Relevant methods include:

    getWallpaperFile(int)

    setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which)