title: getSurfaceTexture() returning null
body: <p>I have the following code:</p>
  
  <pre><code>LayoutInflater factory = LayoutInflater.from(this);
  View view_with_buttons_on = factory.inflate(R.layout.buts, null);
  view_with_buttons_on.setBackgroundColor(Color.TRANSPARENT);
  
  game_frame_layout = new FrameLayout(getApplicationContext());
  surface_view_extension = new SurfaceViewExtension(getApplicationContext());
  game_frame_layout.addView(surface_view_extension);
  game_frame_layout.addView(view_with_buttons_on);
  
  setContentView(game_frame_layout);
  
  preview_texture_view = (TextureView) findViewById(R.id.tex1);
  
  try {
      camera.setPreviewTexture(preview_texture_view.getSurfaceTexture());
  } catch (IOException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>The layout buts.xml contains a set of buttons as well as a <code>TextureView</code> labelled <code>"@id/tex1"</code>.
  It appears that <code>preview_texture_view.getSurfaceTexture()</code> is returning null. The documentation says: </p>
  
  <blockquote>
    <p>This method may return null if the view is not attached to a window or
    if the surface texture has not been initialized yet.</p>
  </blockquote>
  
  <p>I assume the surface must already be attached to a window because the buttons are visible, so I guess my mistake must be not having initialized preview_texture_view - but I have no idea what it means to "initialize" preview_texture_view other than what I have already done. I have seen some related sample code and can not figure out any initialization process.</p>
  
  <p><strong>EDIT:</strong> Maybe it takes a little time to attach to the window or the be initialized. Maybe I need to set up a callback for when its ready?.. just guessing.</p>