If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
mohunt
Posts: 31
Registered: ‎08-26-2011
My Device: Torch 9810
My Carrier: AT&T
Accepted Solution

Unable to lock focus

[ Edited ]

Hi,

 

I am developing an app that uses the camera on a Torch 9810 using SDK 7.1.  I am attempting to use the

EnhancedFocusControl to set and lock the focus.  My code is below:

 

public CameraImageCapture()
	{
	    try
	    {
	    	_camera = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
	        _camera.realize();
	        _cameracontrol = (VideoControl) _camera.getControl("VideoControl");
	        if (_cameracontrol != null)
	        {
	            Field videoField = (Field) _cameracontrol.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
                _cameracontrol.setDisplayFullScreen(true);
                _cameracontrol.setVisible(true);
                _camera.start();
                _efc = (EnhancedFocusControl) _camera.getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
                if (_efc != null)
                {
                	if (_efc.isFocusModeSupported(EnhancedFocusControl.FOCUS_MODE_CONTINUOUS)) {
                		_efc.setFocusMode(EnhancedFocusControl.FOCUS_MODE_CONTINUOUS);                    
                	}
                	try
                	{
                	_efc.startAutoFocus();
                	}
                	catch (Exception e1)
                	{
                		Dialog.alert(e1.toString());
                	}
                }
                if(videoField != null)
                {
                    add(videoField);
                }
	        }
	    }
	    catch(Exception e)
	    {
	    	Dialog.alert(e.toString());
	    }
	}

 

 

When I attempt to call EnhancedFocusControl.startAutoFocus I get the following error:

 

javax.microedition.media.MediaException: Unable to lock focus.   I have noticed few others have had this problem using the sample program but have not received an answer.  Is there a solution for this problem?

 

 

 

Please use plain text.
Contributor
mohunt
Posts: 31
Registered: ‎08-26-2011
My Device: Torch 9810
My Carrier: AT&T

Re: Unable to lock focus

I found that if I moved the EnhancedFocus control into the invokeAction function it was able to set the focus.

Please use plain text.