0

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!

Tom Taylor
  • 3,344
  • 2
  • 38
  • 63
Michael Paccione
  • 2,467
  • 6
  • 39
  • 74
  • 1
    this might help you [LINK] (https://stackoverflow.com/questions/40477253/android-how-to-use-camera-getsupportedpreviewsizes-for-portrait-orientation) – Pashyant Srivastava May 18 '21 at 04:39

1 Answers1

0

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);
}
Mureinik
  • 297,002
  • 52
  • 306
  • 350