需要修改的地方
1.InactivityTimer.java
public synchronized void onActivity() {
...
if (Build.VERSION.SDK_INT < 11) {
inactivityTask.execute();
}else{
inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
2.AutoFocusManager.java
public synchronized void onAutoFocus(boolean success, Camera theCamera) {
if (active) {
outstandingTask = new AutoFocusTask();
if (Build.VERSION.SDK_INT < 11) {
outstandingTask.execute();
} else {
outstandingTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
}
3.CameraManager.java (报W/CaptureActivity(24188): java.io.IOException: setPreviewDisplay failed异常,需要给SurfaceHolder设置type, surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);)
@Override
protected void onResume() {
...
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
SurfaceHolder surfaceHolder = surfaceView.getHolder();
if (Build.VERSION.SDK_INT < 11) {
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (holder == null) {
Log.e(TAG, "*** WARNING *** surfaceCreated() gave us a null surface!");
}else{
if (Build.VERSION.SDK_INT < 11) {
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
}
if (!hasSurface) {
hasSurface = true;
initCamera(holder);
}
}
4.CameraConfigurationManager.java (报 java.lang.NoSuchMethodError: android.view.Display.getSize)
void initFromCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point theScreenResolution = new Point();
if (Build.VERSION.SDK_INT < 13) {
theScreenResolution.x = display.getWidth();
theScreenResolution.y = display.getHeight();
} else {
display.getSize(theScreenResolution);
}
screenResolution = theScreenResolution;
Log.i(TAG, "Screen resolution: " + screenResolution);
cameraResolution = findBestPreviewSizeValue(parameters, screenResolution);
Log.i(TAG, "Camera resolution: " + cameraResolution);
}