title: Draw background of custom View from .png file on Android
body: <p>I created a custom View by extending from View. In onDraw() I managed to draw some circles and other stuff. But now I want to add a background from a resource (sd card or a stream) which is actually a map I download from our server and than draw on it. It's for Android 8+</p>
  
  <pre><code>@Override
  protected void onDraw(Canvas canvas) {
      Canvas g = canvas;
      String file = "/mnt/sdcard/download/tux.png";
      Bitmap bg = null;
      try {
          bg = BitmapFactory.decodeFile(file);
          g.setBitmap(bg);
      } catch (Exception e) {
          Log.d("MyGraphics", "setBitmap() failed according to debug");
      }
  }
  </code></pre>
  
  <p>Somehow g.setBitmap(bg) keeps failing, I haven't looked at the image specs, but actually it's just a tux image (no 24 bits colors) of PNG format.
  Can someone give me some tips how to add a background image so I can draw on it?
  Thank you.</p>