0

If I use the mipmap icon as smallIcon of a Notification in Android O, when notify it, the system ui will crash. But it works below O, and if I change the icon with res in drawable directory, it works as well. Although Google tell us we should place our app icons in mipmap dirs, why I can not use it as the notification icon in Android O?

NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(this, channelId)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(notification.getTitle())
                .setContentText(notification.getBody())
                .setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setContentIntent(pendingIntent);
Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31
wqycsu
  • 290
  • 2
  • 16
  • Probably just [a bug](https://issuetracker.google.com/issues/69109923). – CommonsWare Nov 15 '17 at 13:34
  • @CommonsWare I find that below `Android O`, the result of `getDrawable` from `mipmap` res is `BitmapDrawable`, and on `Android O` it is `AdaptiveIconDrawable`, and it makes `createBitmap` fail during notification execution flow. – wqycsu Nov 16 '17 at 02:40

0 Answers0