BlackBerry Forums Support Community

BlackBerry Forums Support Community (
-   Developer Forum (
-   -   Enabling Flash light for some time on Blackberry. (

imran2k1 01-07-2010 12:38 AM

Enabling Flash light for some time on Blackberry.
Hi every one!
i am making a small application to on the camera Flash light for desire time.
but it is not working on my BB 8900.
i am new to develop so, please help me.
if any error and wrong way is in my code?

public class Screen_1 extends MainScreen{

HorizontalFieldManager Hrm;
Player p;
FlashControl flashControl;
CameraControl cameracontrol;
SnapshotControl snapcontrol;

public Screen_1() {

LabelField mylabel=new LabelField("MY TOURCH",Field.USE_ALL_WIDTH);
add(new RichTextField("Do you want, Flash light ON?"));

/* initializing the player */
p= Manager.createPlayer("capture://video");
catch(IOException me){Dialog.alert("IOException in NO:" + me);}
catch (MediaException me){Dialog.alert(" MediaException in NO: " + me);}

FieldChangeListener yesButton= new FieldChangeListener()
public void fieldChanged(Field field, int context)

flashControl= (FlashControl)p.getControl("javax.microedition.amm");

int test_mode =flashControl.getMode();
int test_support_mode[] = flashControl.getSupportedModes();
int now_test_mode= flashControl.getMode();
Dialog.alert("yes button");
catch (IllegalArgumentException e){Dialog.alert("Illeglexception in yes:" + e);}

snapcontrol = (SnapshotControl)
p.getControl("javax.microedition.amms.control.came ra.SnapshotControl");



ButtonField yesButtonField = new ButtonField("Yes");
ButtonField noButtonField = new ButtonField("No");
add(new SeparatorField());
Hrm= new HorizontalFieldManager();



while to debug, i have take 3 interger to test, in test_mode i have been getting 1 (off) always and in now_test_mode i have been getting 4(ON) what ever i have been putting in setMode(4);
but when i have been saving it and looking in camera then it is not enabling flash light ON.
and when i am running the code on device it do not ON Flash light!

so, kingly help me and tell me what is bugg.. here!
thanks and Regards
Imran ali

imran2k1 01-08-2010 01:03 AM

i am getting every thing is fine as i think,
but when it is executing the line
snapcontrol = (SnapshotControl)
p.getControl("javax.microedition.amms.control.came ra.SnapshotControl");
snapcontrol.start(1); // giving exception here??
i also tried with this
but still exception.
can any one health how to over come this.
because i think when snapcontrol will start flash will give light.
Thanks and regards

All times are GMT -5. The time now is 09:57 PM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.