With new android API 22 getResources().getDrawable() is now deprecated. Now the best approach is to use only getDrawable().
getResources().getDrawable()
getDrawable()
What changed? <
Now you need to implement like this
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //>= API 21 // } else { // }
Following single line of code is enough, everything will take care by ContextCompat.getDrawable
ContextCompat.getDrawable(this, R.drawable.your_drawable_file)