Enclosed camera calls within a null check
@@ -173,13 +173,17 @@ public class HolidayIOIOActivity extends IOIOActivity {
protected void onStart() {
// Start the camera oreview
camera_ = getCameraInstance();
- Parameters params = camera_.getParameters();
+ Parameters params = null;
+
+ if (camera_ != null) {
+ params = camera_.getParameters();
params.setPreviewFormat(ImageFormat.NV21);
getSmallestPreviewSize(params);
params.setPreviewSize(width_, height_);
//params.setFlashMode(Parameters.FLASH_MODE_TORCH);
params.setWhiteBalance(Parameters.WHITE_BALANCE_AUTO);
camera_.setParameters(params);
+
frame_ = new RGB[width_ * height_];
for (int i = 0; i < frame_.length; ++i) {
frame_[i] = new RGB();
@@ -200,6 +204,7 @@ public class HolidayIOIOActivity extends IOIOActivity {
e.printStackTrace();
}
camera_.startPreview();
+ }
super.onStart();
}
