Disclaimer: I am new to Android development so if this topic deserves
to be bumped down to the Newbie group I'll gladly repost there.
Now for some background...
I intend to write some apps that will make use of the the hardware
camera. I purchased and now have a Nexus One to develop with, but I'm
finding that most of the example apps across the web and in the API
demos which use camera fail on the Nexus with a force close error
resulting from calling setPreviewSize with invalid dimensions
(presumably hardcoded for G1/Dev1 specs). After some quick research I
discovered the getPreviewSize / setPreviewSize pairing for properly
setting the camera on sdk1.5 - 1.6, and indeed I was able to get the
camera preview to function in 1.6 APIDemo by substituting:
parameters.setPreviewSize(w, h);
with:
parameters.setPreviewSize(parameters.getPreviewSize().width,
parameters.getPreviewSize().height);
inside of surfaceChanged()
So this is a pretty quick fix for sdk 1.5-1.6, or rather its what
should have been used all along as a method of ensuring you support
future unknown camera specs (although I'm sure there's more to it than
that as the resulting preview had a bad aspect ratio on account of the
status bar still taking screen real estate). But where does this leave
us going forward with development on sdk 2.0, 2.1, and future
releases?
The camera api in 2.0 gives us getSupportedPreviewSizes(), but whereas
the previous api had us comfortably in a one-to-one relationship
between getPreviewSize & setPreviewSize, 2.0, 2.1 can potentially
return several resolutions. So here's my real meat and potatoes
question: Just as the get/set methods were the "best practices" camera
solution for camera previews in 1.5, 1.6 what should be the similar
best practice to handle multiple camera resolutions from
getSupportedPreviewSizes in 2.0 and up?
Off the top of my head I thought of calling getSupportedPreviewSizes()
at the apps first run after install/upgrade and then storing the list
in preferences or another suitable place where a settings activity has
access to it and then iterating the list (still in that first run) to
chose an appropriate default and begin to use it. As I said in the
disclaimer I'm still new so I don't know how doable that is or if it
might be a bad choice for reasons unknown to me.
Opinions?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en