I use the android camera and allow the user to take stills, but I would also like to also allow the user to toggle the ability to use flash. From off/on/auto

This button will be overlayed on the camera just like in the default android camera application. But I do not want to use that application.

How would I do this? I understand Camera.Parameters, but if I added a button on the layout that added key/value pairs to camera.parameters, would I need to refresh the camera? I will eventually try this (sometimes just typing out problems helps me come up with ideas), but any insight would be appreciated!

有帮助吗?

解决方案

You can change the Camera parameters at any time (after you have your camera object).

http://developer.android.com/reference/android/hardware/Camera.Parameters.html

Use whatever settings you want, and attach them to whatever you want your buttons to look like. It's 100% straight forward.

here's a sample from something I did...

    Camera.Parameters cp = mCamera.getParameters();
    cp.setJpegQuality(100);
    cp.setColorEffect(Parameters.SCENE_MODE_PORTRAIT);
    cp.setFlashMode(Parameters.FLASH_MODE_ON);
    cp.setColorEffect(Parameters.EFFECT_MONO);
    setPictureSize(cp);
    mCamera.setParameters(cp);

You can call setParameters at any time, and they will take effect immediately.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top