I am using leakcanary
detect memory leaks on Android. First time using WallpaperManager
. I don't know if you recycle
or clean the WallpaperManager
on destroy.
val wallpaperManager = WallpaperManager.getInstance(this)
wallpaperManager.setStream(file.inputStream())
I think these two lines of code are causing this issue, because if I comment these two lines the memory leak is not occuring.
private fun setWallpaper() {
val dir = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)!!.absoluteFile
val file = File("$dir${File.separator}wallpaper.jpg")
val wallpaperManager = WallpaperManager.getInstance(this)
wallpaperManager.setStream(file.inputStream())
toast(getString(R.string.wallpaper_set_successfully))
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…