title: holder.getSurface().isValid() is returning false
body: <p>I am using  Surfaceview to change the background image. But I am getting false on holder.getSurface().isValid() and I don't know why. I looked at some of the similar questions here, but still could not solve it. Is there something missing on what I have done so far, or is there something else I should try</p>
  
  <p>Thanks</p>
  
  <pre><code>import android.content.Context;
  
  import android.graphics.BitmapFactory;
  import android.graphics.Canvas;
  
  import android.view.SurfaceHolder;
  import android.view.SurfaceView;
  
  
  public class BrickSmasherView extends SurfaceView {
  
  
  
      SurfaceHolder holder;
  
  
  
  
      Canvas canvas;
      Context context;
  
      Thread back = null;
  
      volatile boolean running = false;
  
      public BrickSmasherView(Context context) {
          super(context);
          this.context = context;
          holder = getHolder();
  
      }
      public void runbackThread(){
          back = new Thread(new Runnable() {
              @Override
              public void run() {
                  while (running){
                      draw();
                  }
              }
          });
          back.start();
      }
  
  
  
  
      public  void resumegame(){
          running = true;
         runbackThread();
  
      }
  
      public void pausegame(){
  
          running = false;
          try
          {
              back.join();
  
  
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
  
  public void  draw(){
      if(holder.getSurface().isValid()){
          canvas = holder.lockCanvas();
          canvas.drawBitmap(BitmapFactory.decodeResource(getResources(),R.drawable.sky),0,0,null);
          holder.unlockCanvasAndPost(canvas);
      }
  }
  
  }
  </code></pre>