A summary of how the Android camera supports zooming judgment _android

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.