Recently the boss to a task, said to be in the local video terminal can adjust the camera focal length.
Encountered a number of problems:
1. Phone support does not support camera zoom
2. System with camera software can zoom, but its own programming does not support the zoom,
This problem is also a lot of children's shoes on the internet encountered:
Copy Code code as follows:
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 can be run on LG, but it's crash on the HTC Sensation.
This guy and I have the same problem, my phone is also HTC Sensation Oh.
How does the Android camera zoom:
I checked the api2.2.
It would be nice to call that function.
Copy Code code as follows:
Mcamera.startsmoothzoom (zoom);
However, the call was made without any reaction!
Then, try it:
Copy Code code as follows:
Mcamera.getparameters (). setzoom (zoom);
There's no reaction.
said that the zoom change would call Zoomchangelistener, so I added a listener, but the listener was never called.
Copy Code code as follows:
Mcamera.setzoomchangelistener ();
In fact, the problem is relatively simple:
First: Call Mcamera.getparameters (). issmoothzoomsupported () returns to False, zoom is not supported, setting zoom error
Second: Call Mcamera.getparameters (). iszoomsupported () returns to True,mcamera.getparameters (). issmoothzoomsupported () returns to false, Perhaps the mobile phone with the camera Application support zoom, zoom, but our own application is not. This problem, I do not think of solution now.
So when you're writing a zoom camera or video, use issmoothzoomsupported to judge, so you don't have to crash the other phones that don't support zooming.