VipulSh Ответов: 0

Проблема блокировки обоев экрана в приложении kotlin


I am making a wallpaper app which i was testing in my phone. I used Android 9 Api 28 for the testing purpose. My app has 2 buttons one to set wallpaper and other to set lockscreen wallpaper. My home wallpaper button is working just fine. But my lock screen isnt. First it was showing error when i wrote it. When i hovered over it, it said this feature is supported by API 24 and above so it was giving option to surround it with a if check. I clicked on it and it got it in the if check but error was gone but it wasnt working in my phone still. No logcat error as well. No crashes. I tried it on my brother's phone android 10 api 29. It worked fine. It was meant for api 24 and above but why its not working in api 28 but working in api 29. What should i change in the code to make it work?

Что я уже пробовал:

Я попробовал приведенный ниже код для обоев экрана блокировки. fl_iv в коде-это framelayout, содержащий imageView, который демонстрирует изображение обоев.

<pre><pre lang="kotlin">
<pre>val result: Bitmap = fl_iv.drawToBitmap()

               val wallpaperManager = WallpaperManager.getInstance(this)

               try {
                   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

                       wallpaperManager.setBitmap(result, null, true, WallpaperManager.FLAG_LOCK)
                   }

               } catch (ex: IOException) {
                   ex.printStackTrace()
               }

0 Ответов