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
New Developer
Dquintero16
Posts: 5
Registered: ‎06-16-2009
My Device: Not Specified

Image capture from Blackberry Device

Hi. See, I'm trying to get images using the camera of my Blackberry device using a Java application, but I can't find a decent code snippet I can use in order to do this. I was wondering if anyone can send me a simple code snippet in order to do this. Thanks in advance!

 

Diego Quintero

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Image capture from Blackberry Device

Welcome to the forums.

 

There are two demos shipped with the JDE that provide code to help with this:

 

a) In all 'current' models, the FileExplorer approach, which includes JournalListener code, will work.  Basically you listen for additions of *.jpg files to the File System and process the photo from there (assuming it has come from the camera).

 

b) For 4.6 and above, the camera demo shows you what to do.

 

Alternatively, you can add an ApplicationMenuItem to the Media Explorer so that you pick up photos using it, thoughI have never done this.

 

Good luck.

New Developer
Dquintero16
Posts: 5
Registered: ‎06-16-2009
My Device: Not Specified

Re: Image capture from Blackberry Device

Hi Peter. What JDE you talk about in the first solution? See, the thing is I need to to this for the 4.2 JDE.  I'm trying to use this code snippet to create a player for the camera and set a Video Control in my Form. Does this help or I have to use a completely different way to use the camera within my app? Thanks for your help!

 

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

Item item;
player.prefetch();
player.start();
//Grab the video control and set it to the current display.
videoControl = (VideoControl) (player.getControl("VideoControl"));
item = (Item) videoControl.initDisplayMode(GUIControl.USE_GUI_PRIMITIVE, null);
item.setLayout(Item.LAYOUT_CENTER | Item.LAYOUT_VCENTER);

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Image capture from Blackberry Device

What you are trying to do is option B from @Peter's post. You can only do that in 4.6 and higher. If you need it for 4.2 you need to do option A where you start the built in camera application, and listen for a new file to be written to the device memory. You can then use that image for whatever you want.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Image capture from Blackberry Device

rcmaniac25 is correct, the only other thing I would add is that I believe the FileExplorerDemo which uses the FileSystemJournalListener to pick up new pictures was first shipped with 4.3 JDE.  It works in 4.2 and above (assuming it has been compiled on the correct level of course).

New Developer
Dquintero16
Posts: 5
Registered: ‎06-16-2009
My Device: Not Specified

Re: Image capture from Blackberry Device

Hi Peter. In the example, I can get an Image from the File System, however, I don't quite know how to start the Camera application from my own application to get the picture. I saw that in the JDE 4.5 there's a EmbeddedMediaDemo sample, can I use that to get the picture? I hope you can help me and thanks for all so far.