在某些设备中永远不会触发Picturecallback

时间:2015-09-15 17:30:21

标签: android android-camera android-2.3-gingerbread

单击捕获按钮,首先我启动progressdialog然后我调用PictureCallback。在回调中我解雇了对话框。但是对话框永远不会被解雇,因此不会触发回调。

captureImageButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mProgressDialog != null) {
                        mProgressDialog.setTitle("Please wait");
                        mProgressDialog.show();
                    }
                    captureImageButton.setEnabled(false);

                    if (CameraConfigurationUtils.mCameraInstance != null) {
                        CameraConfigurationUtils.mCameraInstance.takePicture(null, null, mJPEGPictureCallback);
                    }
                }
            });


private Camera.PictureCallback mJPEGPictureCallback = new Camera.PictureCallback() {

    @Override
    public void onPictureTaken(byte[] data, Camera camera) {
        CameraConfigurationUtils.releaseCamera();
        Log.e("DEBUG", "THis is picture call back");
        if (mProgressDialog != null && mProgressDialog.isShowing()) {
            mProgressDialog.dismiss();
        }
        ProcessImageAsyncTask processImageAsyncTask = new ProcessImageAsyncTask(CameraActivity.this);
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            processImageAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, data);
        else
            processImageAsyncTask.execute(data);
    }

0 个答案:

没有答案