|
之前已经有很多文章一直在讲述Android Camera,这里也算是进行以下总结
我们依旧从camera 的打开开始,逐步看看camera的数据流向,内存分配,首先打开camera的第一步,实例化camera类,onCreate被调用,在这个方法中到底做了些什么事情,也在这里做一下总结:
1.实例化FocusManager
2.开启一个CameraOpenThread用于打开camera的全部过程,mCameraOpenThread.start();
3.实例化PreferenceInflater,初始化一些参数
4.实例化TouchManager
5.实例化RotateDialogController等等等
重点是下面几行代码,之前已经不止一次提到,不在多说了
[html]
// don't set mSurfaceHolder here. We have it set ONLY within
// surfaceChanged / surfaceDestroyed, other parts of the code
// assume that when it is set, the surface is also set.
SurfaceView preview = (SurfaceView) findViewById(R.id.camera_preview);
SurfaceHolder holder = preview.getHolder();
holder.addCallback(this);
// don't set mSurfaceHolder here. We have it set ONLY within
// surfaceChanged / surfaceDestroyed, other parts of the code
// assume that when it is set, the surface is also set.
SurfaceView preview = (SurfaceView) findViewById(R.id.camera_preview);
SurfaceHolder holder = preview.getHolder();
holder.addCallback(this);另外这个方法中,还开启了一个startPreviewThread用于开始preview过程,初始化完成之后就开启preview功能
[html]
Thread mCameraPreviewThread = new Thread(new Runnable() {
public void run() {
initializeCapabilities();
startPreview(true);
}
});
Thread mCameraPreviewThread = new Thread(new Runnable() {
public void run() {
initializeCapabilities();
startPreview(true);
}
});这个线程进行初始化之后就调用了app层的startPreview方法,这里开始了万里长征的第一步 |
|