Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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?

What I have tried:

I tried the below mentioned code for the lock screen wallpaper. fl_iv in the code is a framelayout containing an imageView which is showcasing the wallpaper image.

<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()
               }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900