I copied the code from the answer here and I still am getting a RuntimeException: setParameters failed error on my nexus one. My manifest file has camera and wake_lock permissions. This works on the emulator, and on the droid I don't get the error but it does have a rotation problem.
+8
A:
You're most likely requsting an invalid preview size. If you check the results of adb logcat
you'll probably see something like this:
E/QualcommCameraHardware(22732): Invalid preview size requested: 480x724
The solution is to request the closest available preview size to the one you'd like; you can get a list of available preview sizes by calling getSupportedPreviewSizes
in the Camera.Parameters object returned by Camera.getParameters.
Roman Nurik
2010-01-12 22:27:22
You are right, except that it was trying to set it to 320x480 and 480x320 would have worked. This brings me to my next question, why was the SurfaceHolder.Callback.surfaceChanged() method called with such a low resolution that doesn't even match the aspect ratio of the device?
Erik B
2010-01-15 02:33:01
@Erik B -- I realize this is WAY late of a response to this comment, but it's likely because your app is in compatibility mode, and the system is treating pixels in your app as 0.66x the actual device resolution. So 480x800 will be presented to your app as 320x533, probably shaving a few pixels off horizontally or vertically for the status bar unless your activity is fullscreen.
Roman Nurik
2010-10-24 04:01:07