BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Enabling Flash light for some time on Blackberry. (http://www.blackberryforums.com/developer-forum/215916-enabling-flash-light-some-time-blackberry.html)

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() {


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





/* initializing the player */
try{
p= Manager.createPlayer("capture://video");
(Manager.MIDI_DEVICE_LOCATOR);
p.realize();
p.start();
}
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 s.control.camera.FlashControl");


if(flashControl!=null)
{
try{
int test_mode =flashControl.getMode();
int test_support_mode[] = flashControl.getSupportedModes();
flashControl.setMode(FlashControl.FORCE);
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");


//for(;;)
snapcontrol.start(1);





}
};


ButtonField yesButtonField = new ButtonField("Yes");
ButtonField noButtonField = new ButtonField("No");
yesButtonField.setChangeListener(yesButton);
noButtonField.setChangeListener(noButton);
//add(yesButtonField);
//add(noButtonField);
add(new SeparatorField());
Hrm= new HorizontalFieldManager();
Hrm.add(yesButtonField);
Hrm.add(noButtonField);
add(Hrm);


}


}


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

hi
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
snapcontrol.start(Integer.MAX_VALUE);
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 05:47 PM.

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