I found that the useful getResources().getColor(R.color.color_name) is deprecated.
It is not deprecated in API Level 21, according to the documentation.
It is deprecated in the M Developer Preview. However, the replacement method (a two-parameter getColor()
that takes the color resource ID and a Resources.Theme
object) is only available in the M Developer Preview.
Hence, right now, continue using the single-parameter getColor()
method. Later this year, consider using the two-parameter getColor()
method on Android M devices, falling back to the deprecated single-parameter getColor()
method on older devices.