So I'm writing an app for Google Glass that uses the camera to display a preview. The way I have it set up now, the app loads to a main screen from which the user navigates to the camera portion. The preview shows up then an intent is created that takes a picture and the picture is processed. This works 70% of the time; however, occasionally, the app goes to a blackscreen instead of the preview at which point the glass crashes and a hard restart is required.
This is the message from LogCat:
06-18 09:04:05.717: I/CameraService(18740): CameraService::connect X (id 0, this pid is 18740)
06-18 09:04:05.717: I/CameraService-GoogleCamera(18740): Acquire hardware jpeg encoder lock took: 0 mS
06-18 09:04:05.717: D/libgcam(18740): [gcam.cc:3305]: Gcam::Pause
06-18 09:04:05.741: D/debug(9063): ONRESUME
06-18 09:04:05.756: I/Choreographer(9063): Skipped 194 frames! The application may be doing too much work on its main thread.
06-18 09:04:06.413: I/CameraHal(18740): (b79e90f0) hardware/ti/omap4xxx/camera/CameraHalCommon.cpp:114 PPM - PPM: Standby to first shot: Sensor Change completed - :161.11 ms : 1403096646415 ms
06-18 09:04:06.459: I/Choreographer(9063): Skipped 41 frames! The application may be doing too much work on its main thread.
06-18 09:04:06.772: I/ActivityManager(19034): Displayed com.example.d31testing/.CameraActivity: +4s282ms
This is the beginning of the code that I have in OnCreate:
Log.d("debug", "ONCREATE");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_camera);
// determining display dimensions to place the reticle
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
width = size.x;
height = size.y;
Log.d("tag", "x:" + width + "y:" + height);
// Create an instance of Camera
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// code to get camera
mCamera = getCameraInstance();
// Create our Preview view and set it as the content of our activity.
mPreview = new CameraPreview(this, mCamera);
FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
preview.addView(mPreview);
CropDraw mCrop = new CropDraw(this, width, height);
// adding the reticle to the screen
preview.addView(mCrop);
Toast.makeText(
this,
"Press Camera Button to take a picture! \n Take a picture of a side view", Toast.LENGTH_SHORT).show();