Guest post by Johan Larsby.

BlackBerry Express

Following the recent success of BlackBerry Express, we received several questions from developers about how to write plug-ins that serve images for presentations created within the app. Today’s post will address some of those questions.

Similar to other apps, BlackBerry Express can invoke cards.  To familiarize yourself with the process, we created an app that allows you to search through DeviantArt and select an image to use in your presentation. We also created a ”Hello World” project and made a few changes so that it could be launched as a card as well as a standalone app.

First, we modify the bar-descriptor to tell the system that it can be invoked. We also need to change the main function so that it could respond to invocations.

Additionally, this is the signal that we needed to listen to for invocation:

With these steps, we can create an image and send it back. To do this, we fetch the media RSS provided by DeviantArt supplies into a data model we use to populate a list. When an image is chosen, we download and send it to the invoker.

The project is available on GitHub for more information on the steps involved. You can also get more information on invocation on the BlackBerry Developer site.

BlackBerry Express Screen Shot

Invocation documentation

Also provided below pieces of code to help you with the development process:

main.qml

We use “select signal” and “cancel” to communicate to the C++ code when the user has either clicked on an item or pressed cancel:

applicationui.cpp

To get the XML from DeviantArt, we use the built-in DataSource component. Here we listen to the signal on DataLoaded to populate our GroupData model with the relevant information:

RSSDataSource.qml

We created a class that downloads images from the Internet for our ListItem:

ImageSearchListItem.qml

And finally, when the user clicks on an item we download the image and save it:

main.qml:

If you have any questions about this or on how to develop other BlackBerry Express plug-ins, let us know in the comments below.

image

Originally from – 

Build a BlackBerry Express Plugin