문제

I am capturing video using MediaRecorder. The part of the code is given below.

    surfaceView = (SurfaceView) findViewById(R.id.surface_camera);
    mCamera = Camera.open();

    surfaceHolder = surfaceView.getHolder();
    surfaceHolder.addCallback(this);
    surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

But surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); is deprecated. Is there any other methods instead of this method. I want to run my code in all versions.

도움이 되었습니까?

해결책

You can check the SDK version and only call SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS) for older versions.

    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top