我正在尝试在表面支架中显示相机视图。它显示没有摄像头视图的黑屏。我在清单文件中添加了所有权限。
这是我的代码,
public class MainActivity extends FragmentActivity implements LocationListener,
SurfaceHolder.Callback {
SurfaceView surface;
SurfaceHolder sholder;
public void surfaceCreated(SurfaceHolder holder) {
surface = (SurfaceView) findViewById(R.id.surface);
holder = surface.getHolder();
try {
camera = Camera.open();
camera.setPreviewDisplay(holder);
camera.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
}
}
这是我的日志猫,
04-26 12:37:31.569: W/ActivityThread(6125): Application com.example.findproperty is waiting for the debugger on port 8100...
04-26 12:37:31.584: I/System.out(6125): Sending WAIT chunk
04-26 12:37:31.803: I/System.out(6125): Debugger has connected
04-26 12:37:31.803: I/System.out(6125): waiting for debugger to settle...
04-26 12:37:33.420: I/System.out(6125): debugger has settled (1456)
04-26 12:37:33.631: I/ApplicationPackageManager(6125): cscCountry is not German : INS
04-26 12:37:33.733: D/dalvikvm(6125): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
04-26 12:37:33.733: W/dalvikvm(6125): VFY: unable to resolve instance field 23
04-26 12:37:33.733: D/dalvikvm(6125): VFY: replacing opcode 0x52 at 0x0012
04-26 12:37:33.733: D/dalvikvm(6125): VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
04-26 12:37:34.795: W/dalvikvm(6125): Unable to resolve superclass of Lmaps/p/s; (425)
04-26 12:37:34.795: W/dalvikvm(6125): Link of class 'Lmaps/p/s;' failed
04-26 12:37:34.803: W/dalvikvm(6125): Unable to resolve superclass of Lmaps/y/bo; (3818)
04-26 12:37:34.803: W/dalvikvm(6125): Link of class 'Lmaps/y/bo;' failed
04-26 12:37:34.803: W/dalvikvm(6125): Unable to resolve superclass of Lmaps/i/k; (4206)
04-26 12:37:34.803: W/dalvikvm(6125): Link of class 'Lmaps/i/k;' failed
04-26 12:37:34.803: E/dalvikvm(6125): Could not find class 'maps.i.k', referenced from method maps.z.ag.a
04-26 12:37:34.803: W/dalvikvm(6125): VFY: unable to resolve new-instance 3538 (Lmaps/i/k;) in Lmaps/z/ag;
04-26 12:37:34.803: D/dalvikvm(6125): VFY: replacing opcode 0x22 at 0x006d
04-26 12:37:34.850: D/dalvikvm(6125): VFY: dead code 0x006f-007f in Lmaps/z/ag;.a (Landroid/view/LayoutInflater;Lcom/google/android/gms/maps/GoogleMapOptions;ZLjava/lang/String;)Lmaps/z/ag;
04-26 12:37:34.967: D/dalvikvm(6125): GC_CONCURRENT freed 346K, 48% free 3080K/5831K, external 688K/1036K, paused 3ms+4ms
04-26 12:37:35.108: I/ApplicationPackageManager(6125): cscCountry is not German : INS
04-26 12:37:35.725: D/dalvikvm(6125): GC_CONCURRENT freed 264K, 45% free 3284K/5959K, external 688K/1036K, paused 4ms+5ms
04-26 12:37:37.256: D/dalvikvm(6125): GC_CONCURRENT freed 249K, 44% free 3475K/6151K, external 889K/1036K, paused 4ms+4ms
04-26 12:37:38.600: D/dalvikvm(6125): threadid=1: still suspended after undo (sc=1 dc=1)
04-26 12:37:38.702: D/dalvikvm(6125): threadid=1: still suspended after undo (sc=1 dc=1)
04-26 12:37:38.709: D/dalvikvm(6125): GC_CONCURRENT freed 278K, 43% free 3629K/6343K, external 929K/1036K, paused 5ms+5ms
04-26 12:37:58.405: D/SensorManager(6125): ====>>>>>Num Sensor: 1
04-26 12:37:58.405: D/SensorManager(6125): ====>>>>>Num Sensor: 2
04-26 12:37:58.405: D/SensorManager(6125): ====>>>>>Num Sensor: 3
04-26 12:37:58.405: D/SensorManager(6125): ====>>>>>Num Sensor: 4
04-26 12:37:58.413: D/SensorManager(6125): ====>>>>>Num Sensor: 5
04-26 12:37:58.413: D/SensorManager(6125): ====>>>>>Num Sensor: 6
04-26 12:37:58.413: D/SensorManager(6125): ====>>>>>Num Sensor: 0
04-26 12:37:58.420: E/SensorManager(6125): registerListener :: handle = 1 name= BMA222 Acceleration Sensor delay= 20000 Listener= maps.h.a@405d1808
04-26 12:37:58.428: E/SensorManager(6125): =======>>>Sensor Thread RUNNING <<<========
04-26 12:37:58.436: E/SensorManager(6125): reg :: handle = 1
04-26 12:38:02.905: E/SensorManager(6125): unregisterListener:: all sensors, listener = maps.h.a@405d1808
04-26 12:38:03.131: D/libEGL(6125): loaded /system/lib/egl/libGLES_hgl.so
04-26 12:38:03.194: D/BRCM_EGL(6125): eglCreateContext() context: 0x238f60, VC context 1,
04-26 12:39:27.834: D/BRCM_EGL(6125): eglMakeCurrent(NULL) Thread: 6144
04-26 12:39:27.834: D/BRCM_EGL(6125): eglDestroySurface() surface: 0x25a030, android window 0x257bd0, Thread: 6144
清单.xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
为什么我没有得到相机预览?我错过了什么吗?
请帮忙!!!