getColor(int id) deprecated on Android 6.0 Marshmallow (API 23) -
the resources.getcolor(int id) method has been deprecated.
@colorint @deprecated public int getcolor(@colorres int id) throws notfoundexception { return getcolor(id, null); } what can do?
starting android support library 23,
a new getcolor() method has been added contextcompat.
its description official javadoc:
returns color associated particular resource id
starting in m, returned color styled specified context's theme.
so, just call:
contextcompat.getcolor(context, r.color.your_color); you can check contextcompat.getcolor() source code on github.
Comments
Post a Comment