Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 27
Registered: ‎03-08-2011
My Device: 9700
My Carrier: None
Accepted Solution

How to Light the Flash

Hi everyone, i am looking for a solution since 2 days and i can't solve the problem.

I am trying to light the flash of my device, a 9700, but nothing happens. Can you help me ?

 

 

/**
 * HelloWorld.java 
 *
 * Copyright © 1998-2010 Research In Motion Ltd.
 * 
 * Note: For the sake of simplicity, this sample application may not leverage
 * resource bundles and resource strings.  However, it is STRONGLY recommended
 * that application developers make use of the localization features available
 * within the BlackBerry development platform to ensure a seamless application
 * experience across a variety of languages and geographies.  For more information
 * on localizing your application, please refer to the BlackBerry Java Development
 * Environment Development Guide associated with this release.
 */

package com.rim.samples.device.helloworlddemo;
//package com.rim.samples.device.camerademo;
//import lsphone.flash.microfireps;

import java.util.Vector;


//import java.lang.*;
import java.util.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.system.*;
import net.rim.blackberry.api.invoke.*;

import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.media.control.VideoControl;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.util.StringUtilities;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.*;
import java.util.Vector;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import java.io.*;
import net.rim.device.api.system.Alert;
import net.rim.device.api.system.LED;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.media.control.VideoControl;
import javax.microedition.media.*;
import javax.microedition.amms.control.camera.*;
import javax.microedition.amms.control.*;
import javax.microedition.media.Manager.*;
import java.util.Vector;

import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.media.control.VideoControl;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.util.StringUtilities;

public class HelloWorldDemo extends UiApplication
{
    public static void main(String[] args)
    {
        HelloWorldDemo theApp = new HelloWorldDemo();       
        theApp.enterEventDispatcher();
    }
    
    public HelloWorldDemo()
    {        
        pushScreen(new HelloWorldScreen());
        
        LED.setConfiguration( 500, 0, LED.BRIGHTNESS_100 );   
        LED.setColorConfiguration(500, 0, 0x00FFFFFF); 
        LED.setState( LED.STATE_BLINKING );
    }
    
    public static void errorDialog(final String message)
    {
        UiApplication.getUiApplication().invokeLater(new Runnable()
        {
            public void run()
            {
                Dialog.alert(message);
            } 
        });
    }
}



final class HelloWorldScreen extends MainScreen
{

    HelloWorldScreen()
    {   
        setTitle("Hello World Demo");
        add(new RichTextField("Hello World!", Field.NON_FOCUSABLE));

           try 
           {
                    Player p = Manager.createPlayer("capture://video");
                    p.realize();
                    Field _videoField;
                    VideoControl vc = (VideoControl) p.getControl("VideoControl");
                    FlashControl l = (FlashControl) p.getControl("javax.microedition.amms.control.camera.FlashControl");
                    _videoField = (Field) vc.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
                     vc.setDisplayFullScreen(true);
                     vc.setVisible(true);
                     
                    if(l!=null)
                    {
                        if(l.isFlashReady()==true)
                        {
                            HelloWorldDemo.errorDialog("READY");
                            l.setMode(FlashControl.FORCE);
                        }
                        else
                        {
                            LED.setColorConfiguration(500, 0, 0x00FF7F00);
                            LED.setState( LED.STATE_BLINKING );
                            HelloWorldDemo.errorDialog("NOT READY");
                        }  
                 
                    //l.setMode(FlashControl.FORCE_WITH_REDEYEREDUCE);
                    
                      
                    //l.setMode(FlashControl.FORCE_WITH_REDEYEREDUCE);
                    //p.start();
         
                    }
                    else
                    {
                        HelloWorldDemo.errorDialog("NULL");
                    }
                  add(_videoField);
                    p.start();
                    
           
         } 
         catch (Exception e) 
         {
              HelloWorldDemo.errorDialog("EXEPTION");
         }
    }    
    
 
    public void close()
    {
        HelloWorldDemo.errorDialog("Byebye !");  
        LED.setState(LED.STATE_OFF); 
        super.close();
    }   
}

 

 

Thanks very much in advance, i am going to be crazy.

 

Visitor
Posts: 1
Registered: ‎03-09-2011
My Device: BB 9780
My Carrier: o2 - DE

Re: How to Light the Flash

i am going to be crazy too.. jajaja....I search also for a result for this problem.  Do nobody knows a result for it?

 

 

Contributor
Posts: 27
Registered: ‎03-08-2011
My Device: 9700
My Carrier: None

Re: How to Light the Flash

Please help us !

Thanks.

Contributor
Posts: 27
Registered: ‎03-08-2011
My Device: 9700
My Carrier: None

Re: How to Light the Flash

Bump

Contributor
Posts: 27
Registered: ‎03-08-2011
My Device: 9700
My Carrier: None

Re: How to Light the Flash

Plz help me, i am looking for a solution since two days, i tested everything....

Smiley Sad Smiley Sad

Contributor
Posts: 27
Registered: ‎03-08-2011
My Device: 9700
My Carrier: None

Re: How to Light the Flash

Someone have a snippet ?

Developer
Posts: 53
Registered: ‎10-29-2010
My Device: Not Specified

Re: How to Light the Flash

"There are no APIs in the BlackBerry API set that allow you to control the camera flash on a BlackBerry handheld."

 

http://supportforums.blackberry.com/t5/Java-Development/Can-I-control-the-quot-flash-quot-LED/m-p/13...

Contributor
Posts: 27
Registered: ‎03-08-2011
My Device: 9700
My Carrier: None

Re: How to Light the Flash

HOooo Sorry to disturb you....

But how do the FlashLight App on the store ?

i am trying to do it as an alert for some messages.

i am searching since 3 days, 3 days lost...

Thanks

Developer
Posts: 53
Registered: ‎10-29-2010
My Device: Not Specified

Re: How to Light the Flash

[ Edited ]

Hehe, sorry if my answer seemed to be rude, I was just citing what I found in another thread.

 

Maybe your problem is that you can't force the flash. Try configuring it using the camera app and then try your code again.

New Developer
Posts: 27
Registered: ‎03-03-2011
My Device: BB 9700
My Carrier: Vodafone

Re: How to Light the Flash

The App flashlight actually turns on the camera just shrinking its visibility on Screen!

 

You cannot put on FlashLight without turning on the camera!