With new android API 22 getResources().getDrawable() is now deprecated. Now the best approach is to use only getDrawable().
getResources().getDrawable()
getDrawable()
What changed? <
You can use
ContextCompat.getDrawable(getApplicationContext(),R.drawable.example);
that's work for me