From 70799b7b03bfcd7265ce4856dcc96af7cd49223f Mon Sep 17 00:00:00 2001 From: guhongya <1138733232@qq.com> Date: Tue, 20 Dec 2016 16:05:30 +0800 Subject: [PATCH] fix bugs when sdk>=21 and camera fall back toCamera1 (#71) --- .../main/java/com/google/android/cameraview/CameraView.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/src/main/java/com/google/android/cameraview/CameraView.java b/library/src/main/java/com/google/android/cameraview/CameraView.java index 87a7f78e..7ee581ff 100644 --- a/library/src/main/java/com/google/android/cameraview/CameraView.java +++ b/library/src/main/java/com/google/android/cameraview/CameraView.java @@ -230,8 +230,11 @@ protected void onRestoreInstanceState(Parcelable state) { */ public void start() { if (!mImpl.start()) { + //store the state ,and restore this state after fall back o Camera1 + Parcelable state=onSaveInstanceState(); // Camera2 uses legacy hardware layer; fall back to Camera1 mImpl = new Camera1(mCallbacks, createPreviewImpl(getContext())); + onRestoreInstanceState(state); mImpl.start(); } }