BitmapDrawable deprecated alternative

Solution 1:

Do this instead:

return new BitmapDrawable(context.getResources(), canvasBitmap);

Solution 2:

Try this Once.

  1. In Activity

    BitmapDrawable background = new BitmapDrawable(this.getResources(), blurImageBg);
    
  2. In Fragment

    BitmapDrawable background = new BitmapDrawable(getActivity(), blurImageBg);
    
  3. In Adapter or else

    BitmapDrawable background = new BitmapDrawable(context.getResources(), blurImageBg);
    

Solution 3:

Kotlin code for BitmapDrawable:

var bitmapDrawable = BitmapDrawable(resources,bitmapObj)