Use ContextCompat methods.
Make use of ContextCompat
methods such as getDrawable
and getColor
to avoid using deprecated methods on newer versions of Android.
In addition, ContextCompat.getDrawable
makes use of a workaround to correctly retrieve the final configuration density on Android versions older than Jelly Bean.
Edited by Isira Seneviratne