Android getResources().getDrawable() deprecated API 22

With new android API 22 getResources().getDrawable() is now deprecated. Now the best approach is to use only getDrawable(). What changed? 16 s 16 You have some options to handle this deprecation the right (and future proof) way, depending on which kind of drawable you are loading: A) drawables with theme attributes ContextCompat.getDrawable(getActivity(), R.drawable.name); You’ll obtain … Read more

How to convert a Drawable to a Bitmap?

I would like to set a certain Drawable as the device’s wallpaper, but all wallpaper functions accept Bitmaps only. I cannot use WallpaperManager because I’m pre 2.1. Also, my drawables are downloaded from the web and do not reside in R.drawable. 2Best Answer 21 This piece of code helps. Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_resource); Here … Read more