This functionality depends on your Android version.
The method parameters.getMaxZoom() has been appeared since: API Level 8 (Android 2.2), so if you use Android 2.1 this code won't work.
And another thing. You should use your max zoom something like that parameters.setZoom(zoom); instead using constant parameters.setZoom(15);
Also you need to check that user's device support zooming. You can do it like this (only for Android 2.2 and higher)
Camera.Parameters parameters = camera.getParameters();
int maxZoom = parameters.getMaxZoom();
if (parameters.isZoomSupported()) {
if (zoom >=0 && zoom < maxZoom) {
parameters.setZoom(zoom);
} else {
// zoom parameter is incorrect
}
}
But as I know there are no standard API for setting zoom in Android 2.1 I am still investigating this question.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…