title: Glass camera preview display is garbled
body: <p>I am trying to get a live camera preview to display in Google Glass.</p>
  
  <p>I'm using all of the camera defaults (and have also tried using a few different image formats; ideally, I can use one of the YUV formats), but the image that shows up in the display is garbled, like this:</p>
  
  <p><img src="https://i.stack.imgur.com/a6bIU.png" alt="garbled preview image"></p>
  
  <p>The layout is simple:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TextureView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/scan_preview"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" /&gt;
  </code></pre>
  
  <p>Here is the Activity code:</p>
  
  <pre><code>public class ScanActivity extends Activity {
      private static final String kTag = ScanActivity.class.getSimpleName();
      private TextureView mVideoCaptureView = null;
      private Camera mCamera = null;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_scan);
          setTitle(R.string.title_scan);
  
          mVideoCaptureView = (TextureView) findViewById(R.id.scan_preview);
          mVideoCaptureView.setKeepScreenOn(true);
          mVideoCaptureView.setSurfaceTextureListener(new VideoCaptureTextureListener());
      }
  
      @Override
      protected void onPause() {
          super.onPause();
          stopVideo();
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          startVideo();
      }
  
      private void startVideo() {
          if (mCamera != null) {
              mCamera.release();
          }
          mCamera = Camera.open();
          if (null != mVideoCaptureView) {
              try {
                  mCamera.setPreviewTexture(mVideoCaptureView.getSurfaceTexture());
              } catch (IOException e) {
                  Log.e(kTag, "Error setting preview texture", e);
                  return;
              }
          }
          mCamera.startPreview();
      }
  
      private void stopVideo() {
          if (null == mCamera)
              return;
          try {
              mCamera.stopPreview();
              mCamera.setPreviewDisplay(null);
              mCamera.setPreviewTexture(null);
              mCamera.release();
          } catch (IOException e) {
              Log.w(kTag, e);
          }
          mCamera = null;
      }
  
      private final class VideoCaptureTextureListener implements TextureView.SurfaceTextureListener {
  
          @Override
          public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
              stopVideo();
              return true;
          }
  
          @Override
          public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
              startVideo();
          }
  
          @Override
          public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
          }
  
          @Override
          public void onSurfaceTextureUpdated(SurfaceTexture surface) {
          }
      }
  }
  </code></pre>
  
  <p>Do you have any idea why this completely unmanipulated camera preview is not displaying correctly?</p>