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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 59
Registered: ‎06-15-2012
My Device: 9800
My Carrier: XZY

Issue With PictureDemo

 

Hi,

           Good Afternoon every one . today i started to learn picture demo .but i am getting following error

 ERRO: javax.microedition.media.MediaException: Unable to lock focus

 

 

package mypackage;
import net.rim.device.api.ui.*;


public class ImageCaptureDemo extends UiApplication
{
public static void main(String[] args)
{
ImageCaptureDemo app = new ImageCaptureDemo();
app.enterEventDispatcher();
}

public ImageCaptureDemo()
{
pushScreen(new ImageCaptureDemoScreen());
}

}

 

=========================================

package mypackage;

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

import net.rim.device.api.amms.control.camera.EnhancedFocusControl;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;

class ImageCaptureDemoScreen extends MainScreen
{
Player _p;
VideoControl _videoControl;

public ImageCaptureDemoScreen()
{
try
{
_p = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
System.out.println("Camera initialized");
_p.realize();
System.out.println("Getting Accessing Controll");
_videoControl = (VideoControl) _p.getControl("VideoControl");
System.out.println("We get Video Controll");

if (_videoControl != null)
{
System.out.println("Video Controol is not null");
Field videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
System.out.println("We are getting full screen");
_videoControl.setDisplayFullScreen(true);
System.out.println("Set The FullDisplay Screen");
_videoControl.setVisible(true);
System.out.println("make it Done");
_p.start();
System.out.println("Start the lunching the camera");

EnhancedFocusControl efc = (EnhancedFocusControl)_p.getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
efc.startAutoFocus();
System.out.println("Start the autofocus");

if(videoField != null)
{
System.out.println("VideoField Is Not Null");
add(videoField);
}
}
}
catch(Exception e)
{
System.out.println("Error Found"+e);
}
}

protected boolean invokeAction(int action)
{
boolean handled = super.invokeAction(action);

if(!handled)
{
if(action == ACTION_INVOKE)
{
try
{
byte[] rawImage = _videoControl.getSnapshot(null);
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
}
}
return handled;
}
}

 

Need your Your  i am new to this forum as well as blackberry to.

BlackBerry Development Advisor
Posts: 15,888
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Issue With PictureDemo

Which BlackBerry Smartphone model and BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

 

What version of BlackBerry Java SDK are you using?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Highlighted
Developer
Posts: 59
Registered: ‎06-15-2012
My Device: 9800
My Carrier: XZY

Re: Issue With PictureDemo

i am using  6.0