Hi I have a Javascript background and am learning Java... trying to simply output what the supportedPreviewSizes are but I only get a format like this:
android.hardware.Camera$Size@27eefd0
I need to get the width and height. I had tried this:
List<Camera.Size> previewSizes = cParams.getSupportedPreviewSizes();
for (int i = 0; i < previewSizes.size(); i++)
{
// if the size is suitable for you, use it and exit the loop.
Log.d("previewSize", previewSizes.get(0).toString());
break;
}
I don't know why this is so damn hard in Java it doesn't seem intuitive at all. Javascript is way more intuitive console.log(your Object) wow so easy!
The Camera.Size
class doesn't override toString()
, so you get the default implementation, which, as you've seen, isn't very useful. You'll have to manually log the height and the width:
for (int i = 0; i < previewSizes.size(); i++)
{
Camera.Size ps = previewSizes.get(i);
Log.d("previewSize", "height: " + ps.height + ", width: " + ps.width);
}