SoFunction
Updated on 2025-03-11

Summary of the judgment method of whether Android Camera supports zoom

Recently, the boss gave a task, saying that he could adjust the camera focal length on the local video end.

Have encountered some problems:

1. The phone does not support camera zoom

2. The system comes with camera software to zoom, but the program written by yourself does not support zoom.

There are many children's shoes on the Internet that have encountered this problem:

Copy the codeThe code is as follows:

public void setZoomIn(){
    try{
        params = ();
        zoomValue +=5;
        (zoomValue);
        (params);
        (TAG, "Is support Zoom " + ());
    }catch (Exception e) {
        ();
    }
}

This code can run on Lg, but crashed on htc sensing.
This guy has the same problem as me, and my phone is also htc sensing.

How to zoom in android camera:

I checked api2.2
Just call this function

Copy the codeThe code is as follows:

(zoom);

However, there was no response when the call was called!
Then, try:
Copy the codeThe code is as follows:

().setZoom(zoom);

No response, either
It is said that the zoom change will call ZoomChangeListener, so I added the monitor, but the monitor has never been called.
Copy the codeThe code is as follows:

();

In fact, the problem is relatively simple:

First: Calling().isSmoothZoomSupported() returns to false, zoom is not supported, and there is an error in setting zoom

Second: Calling ().isZoomSupported() returns true, and ().isSmoothZoomSupported() returns false. Perhaps the camera application that comes with the phone supports zoom and zoom, but our own application cannot do it. I haven't thought of a way to solve this problem now.

So when writing zoom cameras or videos, use isSmoothZoomSupported to make a judgment, so that there will be no crash on other phones that do not support zoom.