Is there anything you can do to disable this false...
# android
a
Is there anything you can do to disable this false positive lint check when using
use
from KTX, but still have it if you actually don’t recycle the
TypedArray
? (Not this instance of course, but any future instances)
g
Just suppress and report an issue in Android issue tracker
a
(Not this instance of course, but any future instances)
It will take some time before they fix it
So I’m wondering if I can have my cake and eat it too
l
using `use`is different from the extension
withStyledAttributes
?
a
I didn’t know about that one, thanks 👍
1
@leosan Although there is a small difference, with
use
you can return a value, which can be useful sometimes
Copy code
private val foo: Boolean

init {
    foo = context.obtainStyledAttributes()
        .use {
            // do some stuff with it
            it.getBoolean()
        }
}
By the way, there’s already an issue reported https://issuetracker.google.com/issues/79905342
1