在xperia Z2 - 5.1.1中的camera.takePicture()之后调用onPause()并且应用程序崩溃

时间:2016-01-17 06:46:52

标签: android image callback android-camera surfaceview

我正在开发一个使用自定义相机的应用程序,它在我测试的大多数设备上运行良好。

但是在执行 <div class="form-group"> <label class="sr-only" for="form-email">State Option</label> <select name="state_ship" id="state_ship" class="form-control"> </select> </div> 之后的索尼xperia z2(5.1.1)和z ultra(5.1.1)中,流程转到shutterCallback,rawCallback然后调用onPause()并且应用程序崩溃。

请帮助调试此问题。 以下是我的代码。

ButtonClickListener

camera.takePicture(shutterCallback, rawCallback, jpegCallback);

OnPause()方法

clickButton.setOnClickListener(new ImageView.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.v(GlobalMembers.TAG,"shutter clicked");
                //v.startAnimation(AnimationUtils.loadAnimation(ctx, R.anim.shutter_click));
                if(!cameraClicked){  
                    cameraClicked=true;
                    camera.takePicture(shutterCallback, rawCallback, jpegCallback);    
                }
                else{
                    Toast.makeText(ctx, "Please Wait", Toast.LENGTH_LONG).show();
                }

            }
        });


ShutterCallback shutterCallback = new ShutterCallback() {
        public void onShutter() {
            Log.v(GlobalMembers.TAG, "onShutter'd");
        }
    };

    PictureCallback rawCallback = new PictureCallback() {
        public void onPictureTaken(byte[] data, Camera camera) {
            Log.v(GlobalMembers.TAG, "onPictureTaken - raw");
          }
    };

    PictureCallback jpegCallback = new PictureCallback() {
        public void onPictureTaken(byte[] data, Camera camera) {
            try{
                Log.v(GlobalMembers.TAG, "onPictureTaken - jpeg");                   
                cameraClicked=false;
                refreshPreview();                   
                if(data!=null){
                    byte[] rotatedData=rotateImageBeforeSaving(data);
                    setThumbView(rotatedData);
                    new SaveImageTask().execute(rotatedData);
                }
            }catch(Exception e){
                Log.e(GlobalMembers.TAG," Error Occured onPictureCallBack ");
                resetCam();
            }
        }
    };

登录Sony Xperia

@Override
    protected void onPause() {
        Log.v(GlobalMembers.TAG,"onPause Called");
        //thumbView.setTag("Loading");
        if(camera != null) {
            camera.stopPreview();
            camera.setPreviewCallback(null);
            camera.lock();
            preview.setCamera(null);
            camera.release();
            camera = null;
        }
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        super.onPause();
    }

登录Lg G3

onPictureTaken - raw   
01-17 11:43:36.448 1350-1350/com.hybrid.probuk.selfiePro V/SMARTSELFIEPRO: onPause Called
01-17 11:43:42.238 1350-1350/com.hybrid.probuk.selfiePro V/SMARTSELFIEPRO: Inside setCamera
01-17 11:43:42.239 1350-1383/com.hybrid.probuk.selfiePro W/CameraBase: Camera service died!

0 个答案:

没有答案