Trying to load icons for applications on the phone...
# android
m
Trying to load icons for applications on the phone, I use the following code:
Copy code
val drawable = packageManager.getApplicationIcon(app.packageName)
Icon(
    drawable.toBitmap(config = Bitmap.Config.ARGB_8888).asImageBitmap()
    , contentDescription = "Icon", modifier = Modifier
        .padding(8.dp),
    tint = MaterialTheme.colorScheme.secondary
)
This gives a round filled circle and no icon for most apps. why?
Ok, turns out you shouldn’t pass a bitmap to an icon and expect all colors to be preserved.