-1

How can I get (int) resource-id of specific density (hdpi, xhdpi, etc) of the app-icon in Android?

I know we can get drawable object of specific density using getDrawableForDensity() method, but how to get resource id of this drawable?

Ashwin
  • 7,277
  • 1
  • 48
  • 70
  • A given resource has the same ID for each density. That is, resource IDs don't change with density. – Mike M. Jun 08 '18 at 01:21
  • @MikeM. you are right and that is the problem. I need to set notification small icon and I need the resource ID for this purpose. Because some apps might use vector drawables or adaptive icons as their app icon, in that case the app crashes (RemoteServiceException: Bad notification posted) if my library blindly sets the adaptive app icon as small icon for the notification. – Ashwin Jun 10 '18 at 06:19

1 Answers1

1

Android doesn't need you to do this. Each device density is automatically referenced once you add the resources. However, you should use vector drawables where necessary.

Mbuodile Obiosio
  • 1,463
  • 1
  • 15
  • 19