View Single Post
Old 01-07-2010, 01:38 AM   #1 (permalink)
imran2k1
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 01:40 AM. Reason: spell error
Offline   Reply With Quote