Thanks a lot four your answer!

I see that this function is supported since API level 5.

When I try to call it from the emulator running level 5 and higher I
always receive a null-list back when asking for
getSupportedPictureSizes. This is a bit inconvenient but I can work
around that. I keep my fingers crossed and hope it will work on a
Nexus :-)

In order to support also lower API levels, I changed my code to this:

...
try { //check if method is available
  Camera.Parameters.class.getMethod("getSupportedPictureSizes", new
Class[] { });
} catch (NoSuchMethodException nsme) {
    return someDefaultSize;
}
List<Size> supportedSizes  = parameters.getSupportedPictureSizes();
...
/* Evaluate best fitting size and return it */


I am wondering if this is good practice. I also read this artical
about the compatibility topic:
http://developer.android.com/resources/articles/backward-compatibility.html
But I didn't manage to apply the there proposed solution "Using
reflection" with a cached method to this problem....





On 12 Jan., 07:35, Wu-cheng Li (李務誠) <[email protected]> wrote:
> On Mon, Jan 11, 2010 at 8:51 PM, Dani <[email protected]> wrote:
> > Hello
>
> > I keep getting error messages when running my photo applications on a
> > Nexus One with api version 7 when the program tries to set the camera
> > parameters:
>
> > ...
> > Camera.Parameters parameters = camera.getParameters();
>
> Please call getSupportedPreviewSizes to get valid preview sizes. 533x320 is
> invalid on Nenus 
> One.http://developer.android.com/reference/android/hardware/Camera.Parame...()
>
> > parameters.setPreviewSize(w, h); // data set: w:533, h:320
>
> camera.setParameters(parameters);> ...
>
> > ...
> > Camera.Parameters parameters = camera.getParameters();
>
> Please call getSupportedPictureSizes to get valid picture 
> sizes.http://developer.android.com/reference/android/hardware/Camera.Parame...()
>
> > parameters. setPictureSize(w, h); // data set w:1280, h:768
>
> camera.setParameters(parameters)
>
>
>
> > ...
>
> > The prorgram works fine on various other mobile phones such as moto
> > droid or HTC Hero.
>
> > Any idea what it could be? I would appreciate some help!
>
> > cheers
> > Dani
>
> > ----------------------------------------------
> > The stack trace I get is:
> > ----------------------------------------------
> > java.lang.RuntimeException: setParameters failed
> >       at android.hardware.Camera.native_setParameters(Native Method)
> >       at android.hardware.Camera.setParameters(Camera.java:619)
> >       at dk.android.bcFiler.PreviewSurface.surfaceChanged
> > (PreviewSurface.java:149)
> >       at android.view.SurfaceView.updateWindow(SurfaceView.java:460)
> >       at android.view.SurfaceView.dispatchDraw(SurfaceView.java:287)
> >       at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
> >       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
> >       at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
> >       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
> >       at android.view.View.draw(View.java:6538)
> >       at android.widget.FrameLayout.draw(FrameLayout.java:352)
> >       at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
> >       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
> >       at android.view.View.draw(View.java:6538)
> >       at android.widget.FrameLayout.draw(FrameLayout.java:352)
> >       at com.android.internal.policy.impl.PhoneWindow$DecorView.draw
> > (PhoneWindow.java:1830)
> >       at android.view.ViewRoot.draw(ViewRoot.java:1349)
> >       at android.view.ViewRoot.performTraversals(ViewRoot.java:1114)
> >       at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
> >       at android.os.Handler.dispatchMessage(Handler.java:99)
> >       at android.os.Looper.loop(Looper.java:123)
> >       at android.app.ActivityThread.main(ActivityThread.java:4363)
> >       at java.lang.reflect.Method.invokeNative(Native Method)
> >       at java.lang.reflect.Method.invoke(Method.java:521)
> >       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> > (ZygoteInit.java:860)
> >       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
> >       at dalvik.system.NativeStart.main(Native Method)
>
> > --
> > 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]<android-developers%2Bunsubs 
> > [email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
-- 
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

Reply via email to