title: Android canvas drawBitmap throwing null pointer exception
body: <p>Trying to add a simple background to my surface view but theres seems to be an issue with drawBitmap. I'm following a youtube tutorial and he did everything the same except I made my own drawable xml layout file because he didn't show his, so I supposed the issue might lie in the simple.xml file. </p>
  
  <p>Error</p>
  
  <pre><code>com.example.adam.hilo E/AndroidRuntime: FATAL EXCEPTION: Thread-2096
  com.example.adam.hilo E/AndroidRuntime: Process: com.example.adam.hilo, PID: 19788
  com.example.adam.hilo E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
  com.example.adam.hilo E/AndroidRuntime: at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1281)
  com.example.adam.hilo E/AndroidRuntime:  at android.graphics.Canvas.drawBitmap(Canvas.java:1337)
  com.example.adam.hilo E/AndroidRuntime: at com.example.adam.hilo.Activity_Staircase_Layout.run(Activity_Staircase_Layout.java:36)
  com.example.adam.hilo E/AndroidRuntime: at java.lang.Thread.run(Thread.java:818)
  </code></pre>
  
  <p>Activity_Staircase_Layout</p>
  
  <pre><code>public class Activity_Staircase_Layout extends SurfaceView implements Runnable {
  
      Thread thread = null;
      boolean can_draw;
  
      Bitmap background;
      Canvas canvas;
      SurfaceHolder surface_holder;
  
      public Activity_Staircase_Layout(Context context) {
          super(context);
          surface_holder = getHolder();
          background = BitmapFactory.decodeResource(getResources(), R.drawable.simple);
      }
  
      @Override
      public void run() {
          while(can_draw) {
              if(!surface_holder.getSurface().isValid()) {
                  continue;
              }
  
              canvas = surface_holder.lockCanvas();
              canvas.drawBitmap(background,0,0,null);
              surface_holder.unlockCanvasAndPost(canvas);
          }
      }
  
      public void pause() {
          can_draw = false;
  
          while(true) {
              try {
                  thread.join();
                  break;
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
  
          thread = null;
      }
  
      public void resume() {
          can_draw = true;
          thread = new Thread(this);
          thread.start();
      }
  }
  </code></pre>
  
  <p>drawable/Simple.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle"&gt;
  
      &lt;!-- Specify a semi-transparent solid green background color --&gt;
      &lt;solid android:color="#5500FF66" /&gt;
  
      &lt;!-- Specify a dark green border --&gt;
      &lt;stroke
          android:width="5dp"
          android:color="#009933" /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>StaircaseActivity.java</p>
  
  <pre><code>public class StaircaseActivity extends AppCompatActivity {
  
      Activity_Staircase_Layout staircase_LayoutView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          staircase_LayoutView = new Activity_Staircase_Layout(this);
          setContentView(staircase_LayoutView);
      }
  
      @Override
      public void onPause() {
          super.onPause();
          staircase_LayoutView.pause();
      }
  
      @Override
      public void onResume() {
          super.onResume();
          staircase_LayoutView.resume();
      }
  
  }
  </code></pre>