2
私はアクティビティがあり、その中にフラグメントがあります。そのフラグメントにはカスタムカメラが含まれているため、カメラのすべてのコーディングがフラグメントで行われますが、ピクチャはアクティビティから呼び出されます。フラグメントがオンになっているonPictureTake
private void takePicture() {
if (CameraFragment.mIsSafeToTakePhoto) {
camFrag.setSafeToTakePhoto(false);
//CameraFragment.mOrientationListener.rememberOrientation();
// Shutter callback occurs after the image is captured. This can
// be used to trigger a sound to let the user know that image is taken
Camera.ShutterCallback shutterCallback = null;
// Raw callback occurs when the raw image data is available
Camera.PictureCallback raw = null;
// postView callback occurs when a scaled, fully processed
// postView image is available.
Camera.PictureCallback postView = null;
// jpeg callback occurs when the compressed image is available
CameraFragment.mCamera.takePicture(shutterCallback, raw, postView, camFrag);
}
}
テイク絵は
問題は、写真を撮った後、ある、今、図書館法 です。 OnPictureTakeが呼び出され、この段階でフラグメントがアクティビティから切り離され、getActivityはNULLを返します。明示的にアクティビティを定義するとエラーが発生し、フラグメントはアクティビティに関連付けられません。
次のコードは画像を撮影するためのコードです。
@Override
public void onPictureTaken(byte[] data, Camera camera) {
rotation = getPhotoRotation();
CameraModel cameraModel = new CameraModel();
cameraModel.setCameraData(data, rotation, mImageParameters.createCopy());
setSafeToTakePhoto(true);
}
ここで、cameraModelは、DATAのゲッターとセッターです。