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

Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified
Accepted Solution

can't get CameraDemo-like application to work

[ Edited ]

I'm trying to take a snapshot with MMAPI, based on this KB article, and also based on CameraDemo code. I can display the Field and then the simulators prompts for a picture. I select the sample picture, wich becames visible. There are no other fields on this screen, only the Field returned by VideoControl.initDisplayMode in full screen mode. Then I take the snapshot (fired from a TrackwheelClick event) and the returning byte array is null. This is a sample of the code:


// The screen is created, then initialized and pushed: 
synchronized (Application.getEventLock()) {

//CameraScr is a MainScreen, and these are the methods mentioned above:
public void initScreen() {
p = Manager.createPlayer("capture://video");

vc = (VideoControl) p.getControl("VideoControl");
if(vc != null){
viewFinder = (Field)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");

} else {
System.err.println(ERR_TAG + "initScreen(): VideoControl is NULL");
} catch (Exception me){
System.err.println(ERR_TAG + "initScreen(): " + me);

public void start(){
try {
} catch (MediaException e) {
System.err.println(ERR_TAG + "start(): " + e);

//The TrackwheelListener overriden method which fires the snapshot:
public boolean trackwheelClick(int status, int time) {
return true;

//The snap() method:
private void snap(){
byte[] imageBytes = null;
try {
imageBytes = vc.getSnapshot("encoding=jpeg&width=640&height=480&quality=normal");
} catch (MediaException e) {
System.err.println(ERR_TAG + "snap(): " + e);
imageBytes = null;
// After this block, no exceptions are thrown, but imageBytes is always null.

 As you can see, I call Player.start() after the field is added and the screen is displayed, following peter_strange's advice on some other post. I tried also calling start() after initDisplayMode (like in CameraDemo) with no success. I tryed all sort of tricks and no one seems to work.


Tested with:

-BB plugin for eclipse, v1.0.0.67, Component Pack 4.6.0 (Bold 9000 simulator)

-Blackberry 8900 (real device)

-When testing with Component Pack 4.6.1 (8900 simulator), I'm never prompted for an image and the simulator hangs.


Needless to say, I've tested CameraDemo on device (8900) and it does not work, but I think it's because there are other fields on the screen.


Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: can't get CameraDemo-like application to work

[ Edited ]

Ok, I've found what happens.

First of all, old CameraDemo fails because of the button. New CameraDemo (included with JDE 5.0) does not, but it will throw NullPointerException if it is configured with this encoding:


That was causing my app to fail too. Now lets change to this other encoding:


And all will work fine.


This happens also on real devices, so I'm afraid it's a bug. It is really odd because the first encoding is among the Strings returned by this sentence:






New Contributor
Posts: 4
Registered: ‎04-19-2010
My Device: 8530

Re: can't get CameraDemo-like application to work

I was trying to implement an application that uses a camera snapshot screen (similar to camerademo provided by RIM). 


However I get an exception thrown at:

Player player = Manager.createPlayer( "capture://video" );


Here all it says in the exception is source error for net_rim_api.jar.


After a lot of frustration, I create the exact three classes from CameraDemo and also get the same error.  This lead me to believe that it may just be a reference error, source error or having to do with the code signing keys required (although I thought they werent' required for apps to run in the simulator)....


Would anybody be able to clear this frustration for me?