KMC
KMC

Reputation: 1742

BitmapFactory.decodeResource returning null on Tablet device

I have the following code that loads an image to display in an image view. decodeResource returns an image when I use Galaxy S6 as a test device. However, it returns null for the same image when a test device is Galaxy Tab. I noticed that there is 'v24' right next to my image resource name. I just dragged and dropped my image from Finder to Drawable. Could it be because of that?

override fun onStart() {
    super.onStart()


    val image = BitmapFactory.decodeResource(resources, R.drawable.village)

}

Upvotes: 0

Views: 90

Answers (1)

Nicola Gallazzi
Nicola Gallazzi

Reputation: 8713

v24 qualifier means that that drawable is available only for -v24 api and above, you can check api versions here. If you don't have that drawable in the "unversioned" drawable folder BitmapFactory will decode a null drawable. Create your drawable also for lower apis, you can use a useful IntelliJ plugin if your want, called DrawableImporter

Upvotes: 1

Related Questions