3

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.

Ameer
  • 2,709
  • 1
  • 28
  • 44
  • 1
    surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS) was depricated from api level 11 but i have also made an app using it but it works in 4.0 and 4.1 Android OS ,I was also searching for an alternative but was not successful – Auto-Droid ツ Oct 15 '13 at 11:04
  • May later will get some problems – Ameer Oct 15 '13 at 11:10
  • The value is set automatically when needed. That is what document says for android. But if it is less than honeycomb then you should set it – Jimit Patel Apr 12 '15 at 14:20

1 Answers1

4

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);
clinton3141
  • 4,751
  • 3
  • 33
  • 46
Hamid Zandi
  • 2,714
  • 24
  • 32