Vibration and Barcode Extension details, by UCOSP student developer


Continuing the last UCOSP posting, where we talked about the release of the Barcode Scanning Extension for BlackBerry 10 WebWorks, we have some thoughts from another student regarding development of BlackBerry 10 WebWorks Extensions. Developing extensions in C++ that can be called from JavaScript involves some challenges, so if you’ve been thinking about diving in, these hints will be quite useful. Here’s what Alex has to say about his experience this term:

“I had the fortune of joining a number of great software development students as we embarked onto BlackBerry’s new platform, BlackBerry 10. During this term, we explored bbUI.js, BlackBerry Webworks, and the Native Development Kit. I had worked specifically on creating new Webworks community plugins. Two plugins that I had worked on were a vibration feature to allow for additional parameters accessible only through the native development kit and a barcode reading feature with Michael Delong and Tim Windsor. In the end, I had done a great deal of research and developed various approaches to tackle the barcode reading feature.

The vibration community plugin was an effective introduction into developing between Javascript and C++. The feature was originally recommended to be completed when another colleague had required additional granularity in the vibration settings. While I had looked into this issue and was able to flesh it out, we found the APIs themselves were somewhat limiting with how the colleague had envisioned the outcome. Overall this situation was a positive experience in understanding the BlackBerry 10 Webworks architecture and the BlackBerry Platform Services.When developing this plugin I ran into a number of issues due to my own lack of patience which lead to some rather confusing errors.

  • JNext does method invocation through string matching

Somehow through development I was using a certain keyword for indicating my command I wanted to invoke from Javascript. On the C++ side, I seemed to have switched around the naming and thus was expecting to read an event from a keyword that did not exist. Since these constants are being used in two different languages and there is not much common ground between this two language process, nothing was telling me that I was passing in the wrong keyword. Copy and paste can be your friend.

  • Vibration falls under the BlackBerry Platform Services

While creating the vibration code, I was confused why it was not working at all. I had the keywords matching in both Javascript and C++ and it had all compiled from what I could see. Since vibration falls underneath the BPS family, you need to initialize the BPS before it can be used.


After completing this feature, I went on to work with Mike on the barcode scanning feature. Barcode scanning is a relatively interesting concept as it would combine a fairly wide knowledge base of media with my current understanding of Javascript and C++. When working with this feature, initially we tried to piece together what we could from other examples in cascades and the NDK github samples. Requiring a rather large knowledge base was something we had not expected from a feature like barcode scanning. Having to take advantage of input from the camera on the C++ layer introduced us to a number of concepts such as image formats and subsampling. In addition to worrying about these fundamental multimedia concepts we were trying to understand how to take a raw frame from the camera and extract a barcode with the ZXing library. While another of methods were taken in attempting to complete this feature I had participated in two approaches of development to get barcode reading to where it is now on WebWorks.

    1. Displaying the images from a base64 representation from C++ to Javascript layer


  • Attempted to use card invocation to support video feedback for barcode scanning


Prior to this project, I knew of base64 encoding but I had not ever used it in my own development. The ability to encode the bytes of the image in a string was an interesting idea to take advantage of the JNext bridge to carry the image from the native layer to the web layer. Unfortunately during the actual process, the encoding and decoding process can take a fairly long time and actual rendering on the canvas was not fast enough to capture a snappy mobile experience. it was an interesting usage of base64 but this was not quite the answer for the barcode scanner in its current state.

The second attempt that I had looked into was utilizing card invocation to skip the barcode reading altogether and take advantage of a cascades application to do the barcode reading for us. Card invocation is a great idea that can also be seen on other platforms such as Android. Specific functionality that another application may be able to accomplish very well, can be used as a “card”. These cards are invoked from an application which will run that portion of another application. When the card action is complete, that application is closed and the user is returned to the original invoking application. The advantage to this option was visual feedback the user would feel as if it had been built into the Webworks framework and created a fluid native feel to this highly user requested feature, as I was switching into a cascades barcode scanning application. Unfortunately with the card invocation, an application which did the barcode reading would have to exist on the device prior to launching this Webworks application. In addition to this pitfall, Webworks in its current state allows for the ability to query potential cards to handle jobs and the ability to invocate these actions, but was unable to return values. This is an issue if the developer wants to capture a QR code and use this value in their own application. I however did not look into copying the barcode into the clipboard or providing the option to do this however this extra step could be potentially approached by other developers that are fine with running a utility application and a Webworks application.

Overall the experience on BlackBerry 10 with the Webworks framework has been an enjoyable opportunity into the world of mobile web applications. With the ability to utilize open source community driven libraries, BlackBerry has helped build an environment to utilize rich web applications with the raw power of the BlackBerry 10 platform. I look forward to seeing what new applications and innovations can arise from this new way of hybrid mobile/native development.”

You can check out the growing list of BlackBerry 10 WebWorks extensions on our Github repository. The university term is wrapping up now, so our next UCOSP update will have the final thoughts from our last two students and an overview of what the students were able to do this term. If you’re interested in doing some open source coding yourself, I’m putting together some projects for the summer. Contact me through email or twitter.

Join the conversation

Show comments Hide comments
+ -