我正在使用SurfaceView并使用this源代码,但每当我带回图像时,获取:
mediaserver's remote binder Camera object died
Camera service died!
Camera Error 100
Log说:
11-06 12:11:49.691: I/Choreographer(18462): Skipped 38 frames! The application may be doing too much work on its main thread.
11-06 12:11:49.692: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:50.372: I/View(18462): Touch down dispatch to android.widget.Button{41dfb4a8 VFED..C. ......I. 0,0-160,480 #7f050003 app:id/ibCapture}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=76.10486, y[0]=153.67984, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=9951837, downTime=9951837, deviceId=3, source=0x1002 }
11-06 12:11:50.386: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:50.445: I/View(18462): Touch up dispatch to android.widget.Button{41dfb4a8 VFED..C. ...P..I. 0,0-160,480 #7f050003 app:id/ibCapture}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=76.10486, y[0]=153.67984, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=9951911, downTime=9951837, deviceId=3, source=0x1002 }
11-06 12:11:50.445: V/Provider/Settings(18462): get setting for user 0 by user 0 so skipping cache
11-06 12:11:50.446: V/Provider/Settings(18462): from settings cache , name = sound_effects_enabled , value = 0
11-06 12:11:50.679: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:51.768: D/Camera-JNI(18462): Allocating callback buffer
11-06 12:11:51.770: I/CameraFramework(18462): handleMessage: 256
11-06 12:11:51.845: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:52.439: I/View(18462): Touch down dispatch to android.widget.Button{41e14cb0 VFED..C. ......I. 0,240-160,480 #7f050006 app:id/ibUse}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=78.10242, y[0]=71.35135, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=9953906, downTime=9953906, deviceId=3, source=0x1002 }
11-06 12:11:52.462: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:52.513: I/View(18462): Touch up dispatch to android.widget.Button{41e14cb0 VFED..C. ...P..I. 0,240-160,480 #7f050006 app:id/ibUse}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=78.10242, y[0]=71.35135, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=9953980, downTime=9953906, deviceId=3, source=0x1002 }
11-06 12:11:52.513: V/Provider/Settings(18462): get setting for user 0 by user 0 so skipping cache
11-06 12:11:52.513: V/Provider/Settings(18462): from settings cache , name = sound_effects_enabled , value = 0
11-06 12:11:53.231: I/Choreographer(18462): Skipped 42 frames! The application may be doing too much work on its main thread.
11-06 12:11:53.233: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:53.707: I/View(18462): Touch down dispatch to android.widget.Button{41dfb4a8 VFED..C. ......I. 0,0-160,480 #7f050003 app:id/ibCapture}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=69.11365, y[0]=142.7027, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=9955171, downTime=9955171, deviceId=3, source=0x1002 }
11-06 12:11:53.716: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:53.777: I/View(18462): Touch up dispatch to android.widget.Button{41dfb4a8 VFED..C. ...P..I. 0,0-160,480 #7f050003 app:id/ibCapture}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=69.11365, y[0]=142.7027, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=9955243, downTime=9955171, deviceId=3, source=0x1002 }
11-06 12:11:53.778: V/Provider/Settings(18462): get setting for user 0 by user 0 so skipping cache
11-06 12:11:53.778: V/Provider/Settings(18462): from settings cache , name = sound_effects_enabled , value = 0
11-06 12:11:54.024: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.250: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.267: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.284: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.306: I/View(18462): Touch down dispatch to android.widget.Button{41dfb4a8 VFED..C. ......I. 0,0-160,480 #7f050003 app:id/ibCapture}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=157.00378, y[0]=477.00623, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=9960766, downTime=9960766, deviceId=3, source=0x1002 }
11-06 12:11:59.307: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.337: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.353: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.370: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.385: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.408: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.424: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.446: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.468: I/View(18462): Touch up dispatch to android.widget.Button{41dfb4a8 VFED..C. ...P..I. 0,0-160,480 #7f050003 app:id/ibCapture}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=157.00378, y[0]=477.00623, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=9960921, downTime=9960766, deviceId=3, source=0x1002 }
11-06 12:11:59.473: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:11:59.483: V/Provider/Settings(18462): get setting for user 0 by user 0 so skipping cache
11-06 12:11:59.483: V/Provider/Settings(18462): from settings cache , name = sound_effects_enabled , value = 0
11-06 12:12:05.897: D/IPCThreadState(18462): [DN #5] BR_DEAD_BINDER cookie 0x544888c8
11-06 12:12:05.897: W/CameraBase(18462): Camera service died!
11-06 12:12:05.897: D/IPCThreadState(18462): [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x544888c8
11-06 12:12:05.905: D/IPCThreadState(18462): [DN #5] BR_DEAD_BINDER cookie 0x54488bd0
11-06 12:12:05.905: W/CameraBase(18462): mediaserver's remote binder Camera object died
11-06 12:12:05.906: D/IPCThreadState(18462): [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x54488bd0
11-06 12:12:05.935: I/Choreographer(18462): Skipped 387 frames! The application may be doing too much work on its main thread.
11-06 12:12:05.936: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:12:05.957: D/dalvikvm(18462): threadid=11: interp stack at 0x54ba5000
11-06 12:12:05.959: D/dalvikvm(18462): init ref table
11-06 12:12:05.960: D/dalvikvm(18462): init mutex
11-06 12:12:06.032: I/CameraFramework(18462): handleMessage: 1
11-06 12:12:06.034: E/CameraFramework(18462): Error 100
11-06 12:12:06.035: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:12:06.185: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:12:06.264: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:12:06.294: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
11-06 12:12:06.311: I/SurfaceView(18462): updateWindow -- OnPreDrawListener, mHaveFrame = true
CameraPreview.java:
public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
private SurfaceHolder mHolder;
private Camera mCamera;
public CameraPreview(Context context, Camera camera) {
super(context);
mCamera = camera;
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mHolder.setFixedSize(100, 100);
}
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, now tell the camera where to draw the
// preview.
try {
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
} catch (IOException e) {
Log.d("DG_DEBUG", "Error setting camera preview: " + e.getMessage());
}
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
// If your preview can change or rotate, take care of those events here.
// Make sure to stop the preview before resizing or reformatting it.
if (mHolder.getSurface() == null) {
// preview surface does not exist
return;
}
// stop preview before making changes
try {
mCamera.stopPreview();
} catch (Exception e) {
// ignore: tried to stop a non-existent preview
}
// make any resize, rotate or reformatting changes here
// start preview with new settings
try {
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
} catch (Exception e) {
Log.d("DG_DEBUG", "Error starting camera preview: " + e.getMessage());
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
// empty. Take care of releasing the Camera preview in your activity.
}
}
我的设备支持Android Kitkat,所以我可以准确知道我在做什么 - 我错过了什么。为什么我会遇到这个问题?