java - Camera.Parameters device specific crash (Samsung S3 Mini) -
the following code working on galaxy nexus, samsung s3 , htc 1 x crashes on samsung s3 mini
@override public void surfacechanged(surfaceholder holder, int format, int width, int height) { log.d(tag, "entering surfacechanged"); camera.parameters parameters = camera.getparameters(); list<camera.size> previewsizes = parameters.getsupportedpreviewsizes(); // set barcode scene mode if (parameters.getsupportedscenemodes() != null && parameters.getsupportedscenemodes().contains(camera.parameters.scene_mode_barcode)){ parameters.setscenemode(camera.parameters.scene_mode_barcode); log.d(tag, "setting parameters.setscenemode(camera.parameters.scene_mode_barcode)"); } camera.size size = previewsizes.get(0); if (previewsizes.size() > 2) size = previewsizes.get(2); else if (previewsizes.size() > 1) size = previewsizes.get(1); parameters.setpreviewsize(size.width, size.height); log.d(tag, "picsize w: " + integer.tostring(size.width) + " h: " + integer.tostring(size.height)); if (build.version.sdk_int > build.version_codes.honeycomb_mr2) { parameters.setfocusmode(camera.parameters.focus_mode_continuous_picture); log.d(tag, "setting .setfocusmode(camera.parameters.focus_mode_continuous_picture)"); } else { parameters.setfocusmode(camera.parameters.focus_mode_continuous_video); log.d(tag, "setting .setfocusmode(camera.parameters.focus_mode_continuous_video)"); } // setup cam flash mode if (parameters.getsupportedfocusmodes().contains(camera.parameters.flash_mode_auto)){ parameters.setflashmode(camera.parameters.flash_mode_auto); log.d(tag, "setting .setflashmode(camera.parameters.flash_mode_auto)"); } int maxzoom = parameters.getmaxzoom(); int zoom = (int) math.floor(maxzoom / 3); if (parameters.iszoomsupported()) { if (zoom >= 0 && zoom < maxzoom) { parameters.setzoom(zoom); log.d(tag, "setting .setzoom(" + integer.tostring(zoom) +")"); } else { // zoom parameter incorrect log.d(tag, "setting no zoom"); } } camera.setparameters(parameters); camera.startpreview(); }
log output:
8 05-13 10:54:45.864 d/camerasurfaceview(11784): entering surfacechanged 9 05-13 10:54:45.874 d/camerasurfaceview(11784): picsize w: 800 h: 480 10 05-13 10:54:45.874 d/camerasurfaceview(11784): setting .setfocusmode(camera.parameters.focus_mode_continuous_picture) 11 05-13 10:54:45.874 d/camerasurfaceview(11784): setting .setflashmode(camera.parameters.flash_mode_auto) 12 05-13 10:54:45.874 d/camerasurfaceview(11784): setting .setzoom(10) 13 05-13 10:54:45.914 d/androidruntime(11784): shutting down vm 14 05-13 10:54:45.914 w/dalvikvm(11784): threadid=1: thread exiting uncaught exception (group=0x411422a0)
stacktrace:
java.lang.runtimeexception: setparameters failed @ android.hardware.camera.native_setparameters(native method) @ android.hardware.camera.setparameters(camera.java:1452) @ com.getznap.znap.camerasurfaceview.surfacechanged(camerasurfaceview.java:103) @ android.view.surfaceview.updatewindow(surfaceview.java:602) @ android.view.surfaceview.access$000(surfaceview.java:81) @ android.view.surfaceview$3.onpredraw(surfaceview.java:173) @ android.view.viewtreeobserver.dispatchonpredraw(viewtreeobserver.java:707) @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1944) @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1113) @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:4481) @ android.view.choreographer$callbackrecord.run(choreographer.java:725) @ android.view.choreographer.docallbacks(choreographer.java:555) @ android.view.choreographer.doframe(choreographer.java:525) @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711) @ android.os.handler.handlecallback(handler.java:615) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4867) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1007) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:774) @ dalvik.system.nativestart.main(native method)
i'd guess s3 mini has problem 1 of camera parameters. dont't own s3 mini can't test parameters 1 one. there obvious error in code?
it's happen on
parameters.setfocusmode(camera.parameters.focus_mode_continuous_picture);
samsung doesn't support can try
parameters.setfocusmode(camera.parameters.focus_mode_auto);
Comments
Post a Comment