Solution 1 :
Try specifying FLAG_SYSTEM in your wallpaper manager
wallpaperManager.setBitmap(result, null, true, WallpaperManager.FLAG_SYSTEM)
Problem :
I am using a button with id home_screen to set up an image in the framelayout fl_iv as homescreen wallpaper. But when i click on that, it sets up the image as both homescreen wallpaper and lockscreen wallpaper. How to make it just change the home wallpaper? The code goes as:
home_screen.setOnClickListener {
Toast.makeText([email protected], "Please Wait. Setting Up", Toast.LENGTH_SHORT).show()
val result: Bitmap = fl_iv.drawToBitmap()
val wallpaperManager = WallpaperManager.getInstance(this)
try {
wallpaperManager.setBitmap(result)
} catch (ex: IOException) {
ex.printStackTrace()
}
Toast.makeText([email protected], "All Done :)", Toast.LENGTH_SHORT).show()
}
Comments
Comment posted by Vipul Sharma
I tried that but it says that it requires android api level 24 to call this funtion but the minimum set is 22. i was previously using wallpaperManager.setBitmap(result) , it managed to change both home screen and lock screen as low as api 22, so i think there should be a way to a home screen change alone in api 22 and above