单击捕获按钮,首先我启动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);
}