This project contains a full example of a Midlet Java application that employs the Lightstreamer BlackBerry client library
Java
Permalink
Failed to load latest commit information.
lib
res
src/javamedemo/midlet
.gitattributes First commit Jul 29, 2013
.gitignore First commit Jul 29, 2013
BlackBerry_App_Descriptor.xml
LICENSE
README.md
screen_bbslrt.png Add screen bbslrt picture and comatibility note Oct 2, 2013
screen_bbslrt_large.png

README.md

Lightstreamer - Basic Stock-List and Round-Trip Demo - BlackBerry Client

This project contains a full example of a Midlet Java application that employs the BlackBerry Client API for Lightstreamer.

Live Demo

screenshot

View live demo

Details

This BlackBerry application contains two different screens: one with three stock quotes from the Lightstreamer - Stock-List Demos - HTML Clients, the other with four items from the Lightstreamer - Round-Trip Demo - HTML Client. This app uses the BlackBerry Client API for Lightstreamer to handle the communications with Lightstreamer Server.

When the Basic Stock-List Demo is connected, you will see the yellow flashing cells of the Stock-List Demos. Use the menu to switch to the other demo, where you can see the values of some items of the Round-Trip Demo updated in real-time. To publish new values, use the menu.

You can open the Round-Trip Demo on a PC browser and see the values synchronized with the mobile phone.

Dig the Code

The application is divided into 8 main public classes.

  • LightstreamerDemoMidlet: this is the entry point of the application. It extends the MIDlet class to be run as an application and implements the CommandListener interface to receive menu commands. This class is responsible of server connection and table subscriptions.
  • LSDisplayListener: this class extends Canvas: it is the visual part of the application. It also implements the SimpleTableListener as this class is also used to receive updates from the LSClient instance of the LightstreamerDemoMidlet class. This class cannot be used as-is, it is just an abstract class to be used as base to implement real views.
  • LSDisplayListenerStockList & LSDisplayListenerRoundTrip extend the LSDisplayListener showing the data pertaining to the related demo.
  • GraphicsTable is a helper class that is used by LSDisplayListener classes to print a table that fits the monitor in use.
  • SubmitForm is a simple CommandListener that is used to obtain from the user a message to be sent to the server (for the interaction demo part of the demo).
  • ErrorPrompt is a simple CommandListener that is used to show error messages (if any). During development, it can also be used as in-device logging facility.
  • BBConnectionProvider is a key class for the BlackBerry demo. It implements the ConnectionProvider to customize urls before those are used by the Lightstrteamer client library. Url customization is needed by BlackBerry devices to access the Internet through different transports (see here). The current implementation supports WiFi, public MDS, and direct TCP connections.

If you want to skip the build and deploy processes of this demo, please note that you can click the image or link in the Live Demo section above to download a .jad file to your phone. As an alternative, point your mobile browser to the URL: http://demos.lightstreamer.com/bb/lsbbdemo.jad.
Once installed on your phone, run the application, give the requested rights, and wait for the connection to be established (as shown in the top green bar). If no connection can be established but your phone is connecting to the Internet properly for other applications, it probably means that the access point list configured in the demo is not compatible with your phone configuration. You might want to contact support for further information.

Check out the sources for further explanations.

Build

To build your own version of the demo, instead of using the one provided in the Live Demo section above, consider that this example is comprised of the following folders:

  • /src
    Contains the sources to build the java application.

  • /res
    Contains the images needed to the demo.

  • /lib
    Drop here the ls-bb-client.jar from the Lighstreamer SDK for BlackBerry Clients, to be used for the build process and execution.

Getting Started

Unfortunately, at the time of writing, it's not possible to run the demo application with Eclipse and its BlackBerry Java Plug-in because of an issue related to importing external jar files to a project, see here.

So it is necessary to use RIM JDE, which is windows only; download it from http://developer.blackberry.com/bbos/java/download/jde/ and install it. On Windows 7, you may have issues running it from the Programs folder; I suggest you to install it under the user space. Also, to run the IDE, you'll need to use a 32 bit java VM. If your system defaults to a 64 bit JVM, you'll have to edit the ide.bat file located under the JDE_HOME/bin folder. Once ready, launch the IDE, double-clicking the ide.bat file; the JDE should start.

NOTE: If you want to try Eclipse anyway, you can download the BlackBerry plugin from http://us.blackberry.com/developers/javaappdev/javaplugin.jsp. Alternatively, there is an update site located at http://www.blackberry.com/go/eclipseUpdate/3.5/java.

Compile and Run

From inside the JDE, create a new Midlet project by clicking File->New. Then, select the Projects tab and choose Midlet. If necessary, you may have to create a workspace first. Once the project is ready, right-click it and select add files to project. Add all the example files to the project, excluding the lib jar and the BlackBerry_App_Descriptor.xml (it seems that JDE ignores it). Right-click the project again and select properties. In the Application tab, select MIDlet as application type and set LightstreamerDemoMidlet as main class.

Now we have to add the client jar to compile and run the project: From your Lightstreamer installation extract the file included in the Lightstreamer/DOCS-SDKs/sdk_client_blackberry/sdk_client_blackberry7/lib and use that file. In the JDE, create a new Library project and add the jar to it. Then right-click on it and select build project. Finally, right-click on the original project (the one with the sources) and select Project Dependencies; select the other project and click ok. Build it and you should now be able to run the demo.

There a couple of things to keep in mind when building the .cod of the demo with rapc: if you pass the Lightstreamner BlackBerry client library jar ls-bb-client.jar to the rapc as an "import" entry, then you'll have to separately install the Lightstreamer library on the BlackBerry device before you can run the application there. A different approach is to specify the library as a src element. In doing so, the library will be embedded in the final cod. The drawback of this approach is that also the library MANIFEST file and the version files (version.number build.number and compatibility_version.number) of the library will be embedded in the final cod so that you may want to remove such files from the library jar before calling rapc. As a final note, do not specify the lib both as "import" and as "src" or you'll get a "Duplicate definition" error.

Deploy

By the current configuration, specified in LightstreamerDemoMidlet.java and used by the provided precompiled files, the demo tries to connect to the demo server currently running on Lightstreamer website. The demo can be reconfigured and recompiled to connect to the local installation of Lightstreamer Server. Only the host name and the port number have to be changed in the source code. The example requires that the QUOTE_ADAPTER and ROUNDTRIP_ADAPTER have to be deployed in your local Lightstreamer server instance; the LiteralBasedProvider is also needed, but it is already provided by Lightstreamer server.

See Also

Lightstreamer Adapters Needed by This Demo Client

Related Projects

Lightstreamer Compatibility Notes

  • Compatible with Lightstreamer BlackBerry Client API v. 1.1.1 or newer.
  • For Lightstreamer Allegro (+ BlackBerry Client API support), Presto, Vivace.