Can we use VectorDrawable or VectorXML as icons for push notifications in android?

后端 未结 6 1217
故里飘歌
故里飘歌 2021-01-03 21:06

I am using PNG image but its size is getting too big so I have to compromise with its quality. So i was thinking vectors may be the another way around ? Example will be a gr

6条回答
  •  礼貌的吻别
    2021-01-03 21:50

    VectorDrawables will only work as notification icons for versions higher than (or equal to) Android Lollipop - i.e. API 21.

    I know this because I did try using .setSmallIcon(R.drawable.my_vector) as shown in one of the other answers here, and although this works perfectly fine for API 21 and above, I got the following error for versions prior to Lollipop:

    android.app.RemoteServiceException: Bad notification posted from package com.example.app: Couldn't create icon: StatusBarIcon(pkg=com.example.appuser=0 id=0x7f02005a level=0 visible=true num=0 )

    There are also other answers on Stack Overflow supporting this argument:

    • One by CommonsWare
    • Another by ianhanniballake

提交回复
热议问题