In BlackBerry OS 7 and 7.1, there were two ways to interact with the camera:

  1. Invoke the camera application and listen for the resulting file
  2. Use the API (and RIM extensions) to draw the camera inside your app, and capture images/videos there.

With BlackBerry 10, you can accomplish the first by invoking the camera card, and the second by using the Cascades Camera API.

Invoke the Camera Card

This is similar to invoking the Camera App in Java, but more powerful. It is built using the Invocation Framework and with the Camera card, it will seem as though it’s part of your app. You will also prevent the user from going further in your app until they are done with the camera. Use this if you did so before or just want to get a file handle to a photo or video and don’t want to worry about drawing the UI yourself.



Dealing with the result:

Cascades Camera API

This is comparable to what was offered in Java, though it has extra capabilities and is not tied into the Media Player classes. You can easily build a camera viewfinder into your application in pure QML/JavaScript, or C++, or a combination of the two. You can control most functions like focus region, file quality, and viewfinder size/position.

This API will draw the viewfinder wherever you put it on your screen. Similar to Java, it is up to you to create any UI interactions (like tapping to capture a picture). Unlike Java, you also need to play the capture sound yourself, which is required to be on sale in BlackBerry World in certain regions like Japan.

To do Barcodes, connect a BarcodeDetector to a Camera control. You can also do your own detector (or something else) by processing the camera preview frames yourself.

C Camera Library

This is the low-level API that the Cascades API is built on top of. It is very powerful and allows for things that are not available in the Cascades API like burst capture, facial detection, and directly modifying the preview stream. This is far more advanced than the Java API and beyond the scope of this article.

It’s worth noting that the Cascades and C Camera APIs are not compatible. If you would like to use the C API in Cascades, you can draw a viewfinder with the C API and the Foreign Window Control.


Visit site:

BlackBerry Java to BlackBerry 10 Cascades Porting Series – Part 6: Camera