My app is under API < v21, so I use Android Support Library 23.2 for managing my vectorDrawables.
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
All views works ok exept icon for push notification:
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setColor(getResources().getColor(R.color.colorAccent))
.setSmallIcon(R.drawable.ic_play_arrow_white_24dp) //ERROR
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.playing));
I've got the error:
E/AndroidRuntime: FATAL EXCEPTION: main
android.app.RemoteServiceException: Bad notification posted from package com.ashomok.lullabies: Couldn't create icon: StatusBarIcon(pkg=com.ashomok.lullabiesuser=0 id=0x7f020053 level=0 visible=true num=0 )
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1401)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
How can I use vectorDrawable in this case? Is it possible at all?
No, VectorDrawables can only be sent outside your app on Android 5.0+ devices - the framework does not know how to handle vector drawables prior to that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With