0

I spent a lot of time debugging different problems that were reproducible only on a specific devices.

For instance I left my attempts to take a picture from a camera using an Intent. Because only a limited set of the devices behave as expected.

Another example is when I use a byte array from the onPictureTakenCallback:

public void onPictureTaken(byte[] data, Camera camera) {
    byte[] tempData = new byte[data.length];
    System.arraycopy(data, 0, dataTemp, 0, data.length);
    ///...
}

So if I don't make a copy, but use original "data" array some time later then I fall into troubles because some devices clean this array up after a time. But other devices don't do such cleaning so it works perfectly without doing a copy.

One more example: Some devices return null when:

Camera.Parameters params = camera.getParameters();
List<Camera.Size> sizes = params.getSupportedPreviewSizes();
// sizes is null

But most of devices (I think) return a list of supported sizes.

So I wonder if is there any kind of knowledge base / FAQ assembled of such problems? If not, let's post here issues with which we faced?

unorsk
  • 9,371
  • 10
  • 36
  • 42

1 Answers1

1

I'm unaware of it. But byte array you are receiving is mmapped, and in control of another (native) application (and thus data may go at camera application discretion, if it reuses this buffer)

Best way is to copy it away to safe location ASAP

As for preview sizes - they are a mess. Even if you get this list, not all resolutions are supported actually ( I got segfaults on bigger resolutions - somehow preview buffer did not fit ). Only way is to probe whether this preview size is actually supported by activating them in turn and waiting for exc eption

Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35
  • Yeah, but I am looking for a place where I can find all these tricks described (like supported resolutions and many others). Because it is a major pain to headbang every fifteen meters. Probably we could start posting here all weird HW (and not only) related problems? – unorsk Nov 22 '11 at 09:50
  • Yes we can do it. I develop OCR library in java which is used on android - I put together some camera utility classes encapsulating this logic. ( See demos module: http://sourceforge.net/projects/javaocr/ ) I use it in 2 applications, and did not received user complaints yet ( http://www.pribluda.de/android/ocrcall/ ) – Konstantin Pribluda Nov 22 '11 at 09:57