我正在使用一个正在使用相机(CWAC)的Android应用程序,它在更新到Android 5.0.2之前工作正常,更新后如果我拍照,在CameraView中调用camera.takePicture :
postDelayed(new Runnable() {
@Override
public void run() {
try {
camera.takePicture(xact, new PictureTransactionCallback(xact),
new PictureTransactionCallback(xact));
}
catch (Exception e) {
android.util.Log.e(getClass().getSimpleName(),
"Exception taking a picture", e);
// TODO get this out to library clients
}
}
}, xact.host.getDeviceProfile().getPictureDelay());
这是PictureTransactionCallback:
private class PictureTransactionCallback implements
Camera.PictureCallback {
PictureTransaction xact=null;
PictureTransactionCallback(PictureTransaction xact) {
this.xact=xact;
}
@Override
public void onPictureTaken(byte[] data, Camera camera) {
camera.setParameters(previewParams);
if (data != null) {
new ImageCleanupTask(getContext(), data, cameraId, xact).start();
}
if (!xact.useSingleShotMode()) {
startPreview();
}
}
}
问题是,如果我在Android 5.0上运行应用程序onPictureTaken从PictureTransactionCallback永远不会在同一部手机上触发(我用调试运行应用程序),但是启动了android 4.4.2 onPictureTaken并且simpleCameraHost.saveImage是调用。我无法找到问题的原因。