BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 01-07-2010, 12:38 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2010
Model: 8900
PIN: N/A
Carrier: telus
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Post Enabling Flash light for some time on Blackberry.

Please Login to Remove!

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

Last edited by imran2k1 : 01-07-2010 at 12:40 AM. Reason: spell error
Offline  
Old 01-08-2010, 01:03 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2010
Model: 8900
PIN: N/A
Carrier: telus
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.