【Android】-【7.6.5011】:【拍照按钮快速连续点击会导致RuntimeException】
tashuodeni opened this issue · 2 comments
issue标题:
【Android】-【7.6.5011】:【拍照按钮快速连续点击会导致RuntimeException】
issue内容:
【当前现象】:聊天界面点击拍照,进入CameraActivity,快速连续点击拍照按钮会导致 java.lang.RuntimeException: takePicture failed
【集成包】:TUIKIT
【机型】:魅族18Pro
【之前版本有无此问题】:应该一直存在
【有无日志或者描述、截图】:
java.lang.RuntimeException: takePicture failed
at android.hardware.Camera.native_takePicture(Native Method)
at android.hardware.Camera.takePicture(Camera.java:1630)
at android.hardware.Camera.takePicture(Camera.java:1571)
at com.tencent.qcloud.tuikit.tuichat.component.camera.view.CameraInterface.takePicture(CameraInterface.java:327)
at com.tencent.qcloud.tuikit.tuichat.component.camera.state.PreviewState.capture(PreviewState.java:49)
at com.tencent.qcloud.tuikit.tuichat.component.camera.state.CameraMachine.capture(CameraMachine.java:75)
at com.tencent.qcloud.tuikit.tuichat.component.camera.view.CameraView$2.takePictures(CameraView.java:155)
at com.tencent.qcloud.tuikit.tuichat.component.camera.view.CaptureLayout$2.takePictures(CaptureLayout.java:134)
at com.tencent.qcloud.tuikit.tuichat.component.camera.view.CaptureButton$2.onAnimationEnd(CaptureButton.java:220)
at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:600)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1333)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1575)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:326)
at android.animation.AnimationHandler.-$$Nest$mdoAnimationFrame(Unknown Source:0)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:86)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1439)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1449)
at android.view.Choreographer.doCallbacks(Choreographer.java:1097)
at android.view.Choreographer.doFrame(Choreographer.java:1023)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1414)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:8045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)
------------------------- 修复方案 -------------------------
可在PreviewState类中添加标志位
class PreviewState implements State {
private boolean capturing = false;
@Override
public void capture() {
TUIChatLog.i(TAG, "capture");
if (capturing) {
return;
}
capturing = true;
CameraInterface.getInstance().takePicture(new CameraInterface.TakePictureCallback() {
@Override
public void captureResult(Bitmap bitmap, boolean isVertical) {
capturing = false;
String path = FileUtil.generateImageFilePath();
boolean result = FileUtil.saveBitmap(path, bitmap);
if (!result) {
TUIChatLog.e(TAG, "take picture save bitmap failed");
}
machine.getCameraView().showPicture(bitmap, isVertical);
machine.getBrowserPictureState().setDataPath(path);
machine.setState(machine.getBrowserPictureState());
}
});
}
}
92_1703764862.mp4
复现视频