David David - 1 year ago 292
Android Question

getResources().getColor() is deprecated


buildToolsVersion "22.0.1"
targetSdkVersion 22
in my gradle file.

I found that the useful
is deprecated.

What should I use instead?

Answer Source

It looks like the best approach is to use:

ContextCompat.getColor(context, R.color.color_name)

This will choose the Marshmallow two parameter method or the pre-Marshmallow method appropriately.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download