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?
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?
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.
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();
}