我正在关注此链接http://www.vogella.com/articles/AndroidCamera/article.html#tutorial_cameraapi
只有我改变了cameraId = findFrontFacingCamera(); 行至cameraId = findBackFacingCamera();
并编写如下方法:
private int findBackFacingCamera() {
int cameraId = -1;
// Search for the back facing camera
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++) {
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == CameraInfo.CAMERA_FACING_BACK) {
Log.d(DEBUG_TAG, "back Camera found");
cameraId = i;
break;
}
}
return cameraId;
}
我修改了这条线camera.takePicture(null, null, new PhotoHandler(getApplicationContext()));
至
try {
camera.takePicture(null, null, new PhotoHandler(getApplicationContext()));
} catch (Throwable e) {
Log.d("error",""+e);
}
我什么都没改变
我在 Galaxy Fit 上检查的设备
给出错误
07-05 07:09:06.159: D/error(26994): java.lang.NullPointerException