0

I am tring to set an image from URL as wallaper for both home screen and lock screen.it is not working for lock screen for API level 28 or lower but works for home screen.

val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
                    StrictMode.setThreadPolicy(policy)
                    var input: InputStream? = null
                    try {
                        input = URL(intent).openStream()
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                            val wallpaperManager = WallpaperManager.getInstance(applicationContext)
                            wallpaperManager.setStream(
                                input, null, true,
                                WallpaperManager.FLAG_LOCK or WallpaperManager.FLAG_SYSTEM
                            )
                            Toast.makeText(this, "Wallpaper set successfully!", Toast.LENGTH_SHORT)
                                .show()
                        }
                    } catch (e: Exception) {
                        e.printStackTrace()
                    }
Muaz Khan
  • 27
  • 6
  • Please include any error messages you see (might need to look in logcat) as this will help people better understand the issue. – undermark5 Oct 28 '21 at 23:25
  • @undermark5 bro there is no error it just does not apply to the lock screen on being clicked for both screen, however it does work when clicked on the button responsible only for changing lock screen – Muaz Khan Oct 29 '21 at 06:29

0 Answers0