Android Camera whether supports zoom determination method summary

  • 2020-06-19 11:41:24
  • OfStack

Recently, the boss gave me a task to adjust the focus of the camera in the local video terminal.

There are 1 problems:

1. Camera zoom is not supported on mobile phone

2. The camera software of the system can zoom, but the program I wrote does not support zoom.

There are also a lot of children's shoes encountered on the Internet:


public void setZoomIn(){
    try{
        params = camera.getParameters();
        zoomValue +=5;
        params.setZoom(zoomValue);
        camera.setParameters(params);
        Log.d(TAG, "Is support Zoom " + params.isZoomSupported());
    }catch (Exception e) {
        e.printStackTrace();
    }
}

This code works on Lg, but crash works on htc sensation.
This guy is having the same problem as me. My phone is also htc sensation.

How to zoom the android camera?

I checked api2. 2
Just call this function


mCamera.startSmoothZoom(zoom);

However, the call did not have any response!
Then, try:

mCamera.getParameters().setZoom(zoom);

There was no response
Say zoom change will call ZoomChangeListener, so I added the listener, but the listener 1 hasn't been called yet

mCamera.setZoomChangeListener();

The question is simple:

1: Call mCamera.getParameters ().isSmoothZoomSupported () returns false, zoom is not supported, error setting zoom

2: Call mCamera.getParameters ().isZoomSupported () returns true, mCamera.getParameters ().isSmoothZoomSupported () returns false, maybe the phone's built-in camera app supports zoom, zoom, but our own app does not. I can't think of a solution to this problem now.

So use the isSmoothZoomSupported when writing zoom cameras or videos, and you won't find crash on other phones that don't support zoom.


Related articles: