i have 1 question can access android device camera's flash light
programmically.is possible turn on , off flash light programmically? please give me answer . in advance.
package com.thedevelopersinfo.tutorial.android.soundrecordingexample; import java.io.file; import android.app.activity; import android.content.contentresolver; import android.content.contentvalues; import android.content.intent; import android.hardware.camera; import android.media.mediarecorder; import android.net.uri; import android.os.bundle; import android.os.environment; import android.provider.mediastore; import android.provider.mediastore.mediacolumns; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; public class main extends activity { private mediarecorder mediarecorder; private file file = null; static final string prefix = "record"; static final string extension = ".3gpp"; private button b1; camera mcamera; public boolean ison=true; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mcamera = camera.open(); camera.parameters params = mcamera.getparameters(); b1=(button)findviewbyid(r.id.startbtn); b1.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub setflashlight(); } }); } public void setflashlight() { if (mcamera == null) { } camera.parameters params = mcamera.getparameters(); string value; if (ison) // being ask turn on { value = camera.parameters.flash_mode_torch; } else // being asked turn off { value = camera.parameters.flash_mode_auto; } try{ params.setflashmode(value); mcamera.setparameters(params); string nowmode = mcamera.getparameters().getflashmode(); if (ison) { nowmode.equals(camera.parameters.flash_mode_torch); } if (!ison) { nowmode.equals(camera.parameters.flash_mode_auto); } } catch (exception ex) { } } }
but got following exception 03-10 18:47:34.907: error/qualcommcamerahardware(1280): parameter antibanding not supported sensor
Comments
Post a Comment