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.

3
  • 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 Commented Oct 15, 2013 at 11:04
  • May later will get some problems Commented Oct 15, 2013 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 Commented Apr 12, 2015 at 14:20

1 Answer 1

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); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.