// Set camera params final Camera.Parameters params = mCamera.getParameters(); final boolean shouldFlashBeOn = !(Camera.Parameters.FLASH_MODE_ON.equals(params.getFlashMode())); params.setFlashMode(shouldFlashBeOn ? Camera.Parameters.FLASH_MODE_ON : Camera.Parameters.FLASH_MODE_OFF); mCamera.setParameters(params); mCamera.startPrevIEw(); // Set Imagebutton state mImagebuttonFlash.setSelected(shouldFlashBeOn);解决方法 如果我遇到这种情况,我会先检查所有参数.然后找出我可以使用的值.例如,通过以下代码打印所有参数
Parameters param = mCamera.getParameters();Log.i("camera",param.flatten().toString());
然后检查日志
03-18 09:58:08.855: I/camera(32756):
preferred-prevIEw-size-for-vIDeo=1280×720;zoom=0;max-num-detected-faces-hw=5;zoom-supported=true;metering=center;contrast=2;whitebalance=auto;scene-mode=auto;jpeg-quality=100;prevIEw-format-values=yuv420sp,yuv420p;jpeg-thumbnail-quality=100;prevIEw-format=yuv420sp;vIDeo-size-values=1280×720,1920×1080,960×720,720×480,640×480,352×288,320×240,176×144;prevIEw-size=960×720;focal-length=3.700000;iso=auto;fast-fps-mode=0;flash-mode-values=auto,off,on,torch;prevIEw-frame-rate-values=30,20,15,10;prevIEw-frame-rate=30;focus-mode-values=auto,infinity,macro,fixed,continuous-picture,continuous-vIDeo;jpeg-thumbnail-wIDth=160;vIDeo-size=1280×720;scene-mode-values=auto,portrait,landscape,night,beach,sNow,sunset,fireworks,sports,party,candlelight,dusk-dawn,fall-color,text,back-light;prevIEw-fps-range-values=(10000,10000),(15000,15000),30000),(30000,30000);jpeg-thumbnail-size-values=160×120,160×90,144×96,0x0;zoom-ratios=100,102,104,109,111,113,119,121,124,131,134,138,146,150,155,159,165,170,182,189,200,213,222,232,243,255,283,300,319,364,400;prevIEw-size-values=960×720,1280×720,320×240;picture-size-values=640×480,1024×768,1600×1200,2560×1920,3264×2448,2048×1536,3264×1836,2048×1152,3264×2176;prevIEw-fps-range=15000,30000;min-exposure-compensation=-4;antibanding=off;max-num-focus-areas=1;vertical-vIEw-angle=49.3;horizontal-vIEw-angle=63;vIDeo-stabilization-supported=true;jpeg-thumbnail-height=120;smooth-zoom-supported=false;focus-mode=auto;auto-whitebalance-lock-supported=true;vIDeo-frame-format=yuv420sp;picture-format-values=jpeg;max-exposure-compensation=4;focus-areas=(0,0);exposure-compensation=0;exposure-compensation-step=0.5;flash-mode=off;effect-values=none,mono,negative,sepia,solarize,posterize,washed,vintage-warm,vintage-cold,point-blue,point-red-yellow,point-green,cartoonize;picture-size=640×480;max-zoom=30;effect=none;whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;picture-format=jpeg;focus-distances=0.15,1.20,Infinity;auto-exposure-lock-supported=true;antibanding-values=50hz,off
您可以看到可以使用的值
flash-mode-values=auto,torch;
然后通过代码设置其中一个值
param.set("flash-mode","on");mCamera.setParameters(param);
你可以尝试一下.
总结以上是内存溢出为你收集整理的android – 相机FLASH_MODE_ON无法在Moto X上运行全部内容,希望文章能够帮你解决android – 相机FLASH_MODE_ON无法在Moto X上运行所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)