fr3ak
fr3ak

Reputation: 503

Exception while getting application icon android 8, works on android 7

I'm trying to get the large icon for the notification in android app like that:

val bm = BitmapFactory.decodeResource(this.resources, R.mipmap.ic_launcher)

It works correctly in android 7.1, but throws exception in android 8:

Caused by: java.lang.IllegalStateException: bm must not be null

It is the same code, nothing changes. Does someone know whats wrong? I'm using Kotlin(if it matters).

Upvotes: 4

Views: 594

Answers (1)

Artyom
Artyom

Reputation: 1185

It seems that R.mipmap.ic_launcher is not an id of BitmapDrawable resource.
ic_launcher.xml file from mipmap-anydpi-v26 directory is used on Android 8 instead of ic_launcher.png from mipmap-*dpi. It contains adaptive icon resource.

You may try this solution to convert it to a Bitmap.

Upvotes: 3

Related Questions