Question:
I'm analyzing an example of working with a camera and came across a method that returns a list of available resolutions
Size[] sizesJPEG = configurationMap.getOutputSizes(ImageFormat.JPEG);
for (Size item : sizesJPEG) {
System.out.println("w:" + item.getWidth() + " h:" + item.getHeight());
}
and at the exit like this
I/System.out: w:640 h:480
I/System.out: w:352 h:288
I/System.out: w:320 h:240
I/System.out: w:176 h:144
who worked with the camera tell me why we might need this information?
Answer:
Obviously, this information may be needed in order to find out what permissions are available. If you, in a specific application, do not need this information, then you will not ask for it, but if you suddenly need such information, for any purpose, then you know where to get it.
A practical moment can be, for example, to find out if the camera supports shooting in JPEG at all, that is, if the method has not returned a single resolution, then the camera does not shoot in JPEG.
Then, you can offer the user to choose their own settings, in which resolution to shoot – so that he does not bump into something gag when shooting, when either the quality is too low, or too high, or the aspect is not suitable for the photo that is required in your application.
This method can be useful both for helping to display, in fact, a list of available options, and for checking if there is such a permission, if, say, you have a fixed list for all devices, but, as you know, not all permissions supported by all cameras.
You can also combine both options and, based on the information received about the resolutions of a particular camera, create a list of the options you want in the settings (for example, only widescreen) with those that this particular camera supports.
Then you set a fixed resolution, knowing exactly what the camera supports.
Or you can get this information to set the size of the widget to display the captured image, exactly to the size of the photo.
In general, all kinds of APIs contain a large number of classes and methods, many of which you may never need and you will not use them, since they are not required to solve your particular task – this is quite normal.
The presence of some functions in the API does not imply their indispensable use, especially if you find it difficult to figure out how exactly they could be used.
Don't get hung up on this. It's good that you know that there is such an opportunity and someday it will be useful to you. If you do not know how this information could be used, then you personally do not need it in this project. Leave her alone and solve those problems that the current project requires.
If you are very interested in who, how, where and for what uses this method, you can look at the projects where it is used and draw some conclusions for yourself.