Skip to content

This project contains a full example of a Java application that employs the Lightstreamer Android Client library

License

Notifications You must be signed in to change notification settings

Lightstreamer/Lightstreamer-example-StockList-client-android

Repository files navigation

Lightstreamer - Basic Stock-List Demo - Android Client

This project contains a full example of an Android application that employs the Lightstreamer Android Client library.

Note

This demo was replaced by a new one that integrates push notifications: Lightstreamer - MPN Stock-List Demo - Android Client

This demo is still maintained to support the Lightstreamer - Basic Stock-List Demo - BlackBerry (Android Runtime) Client

Live Demo

screenshot QR

(To install the app from the Google Play Store, you can also use the above QR code)

Details

This is a Java-for-Android version of the Lightstreamer - Basic Stock-List Demo - HTML client.
This app uses the Android Client API for Lightstreamer to handle the communications with Lightstreamer Server. A simple user interface is implemented to display the real-time data received from Lightstreamer Server.

Dig the Code

The application is divided into 6 main classes.

  • AndroidUi.java: this class handles the communication to the final Android user interface, like connection status and items updates.
  • LightstreamerListener.java: it's the interface implemented by AndroidUi that receives both data and connection events from the Lightstreamer Client.
  • StockListConnectionListener.java: it's the Lightstreamer ConnectionListener implementation that is passed to LSClient for receiving connection-related events. In this project, this object routes all the events to LightstreamerListener.
  • StocklistHandyTableListener.java: it's the Lightstreamer HandyTableListener implementation that is passed to LSClient for receiving data-related events. In this project, this object routes all the events to LightstreamerListener.
  • LightstreamerClient.java: it's a wrapper class that encapsulates the Lightstreamer LSClient object, exposting start() and stop() methods.
  • StockListDemo.java: the class containing the Android activity entry point, from where Lightstreamer client <-> server connection and Android User Interface (AndroidUi) is initialized.

Check out the sources for further explanations.

NOTE: Not all the functionalities of the Lightstreamer Android Java client are exposed by the classes listed above. You can easily expand those functionalities using the Android Client API as a reference. If in trouble, check out the specific Lightstreamer forum.

Install

If you want to install a version of this demo pointing to your local Lightstreamer Server and running into an Adroid Virtual Device, follow these steps:

  • Note that, as prerequisite, the Lightstreamer - Stock- List Demo - Java Adapter has to be deployed on your local Lightstreamer Server instance. Please check out that project and follow the installation instructions provided with it.
  • Launch Lightstreamer Server.
  • Download the deploy.zip file that you can find in the deploy release of this project and extract the Android_StockListDemo_Basic.apk file.
  • Install the Android_StockListDemo_Basic.apk in your Android SDK.
    • Execute the emulator (SDK Manager.exe->Tools->Manage AVDs...->New then Start)
    • Start the console (i.e., Windows ), Run -> type cmd, and move to the platform-tools folder of SDK directory.
    • Paste the APK file in the 'android-sdk\tools' or 'platform-tools' folder.
    • Then type the following command:
      adb install [.apk path]
      
  • Look up the demo in your virtual device and launch it.

Note that the demo targets the Lightstreamer server @ http://10.0.2.2:8080 because 10.0.2.2 is the special alias to your host loopback interface.

Build

To build your own version of the demo, instead of using the one provided in the deploy.zip file from the Install section above, please consider that this example is comprised of the following folders:

  • /src Contains the sources to build the Java-for-Android application.
  • /res Contains the images and other resourced needed to the demo.
  • /lib Get the ls-android-client.jar file from the Lighstreamer SDK for Android Clients from Lightstreamer distribution (see compatibility notes below) and put it here. The version required by this demo can be found in Lightstreamer Allegro-Presto-Vivace version 5.1.2 to 6.0.

Getting Started

To directly import the project as-is, you need the Eclipse IDE with the Android SDK and Android ADT plugin installed: Go to http://www.eclipse.org/ and download the latest Eclipse distribution in its "classic" package.
Go to http://developer.android.com/sdk/ and follow the instructions to install the Android SDK and ADT plugin in Eclipse. You may want to read more detailed information regarding the required ADT Eclipse plugin, including choosing the best version for your IDE, at: http://developer.android.com/sdk/eclipse-adt.html.
NOTE: You may also use the sources of the demo with another IDE or without any IDE but such approach is not covered in this readme. In any case, you need at least the Android SDK.

You're now ready to import the project into eclipse, click on File->Import... then under General, select Existing Projects into Workspace, and choose the folder where the demo sources are.

Compile and Run

From Eclipse, to compile and run the application, right-click on the project in the Package Explorer and click Run As -> Android Application. If this is the first time an Android application is run, an extra window will appear, asking to create a new Android Emulator Device "Android SDK and AVD Manager". In this case, click on the "New..." button on the right and fill the form entering a name for your Android emulated device, a target platform of your choice, and a SD card size. If you are unsure, select Android 1.1 as target platform and 128Mb as SD card size. Once done, click the "Create AVD" button and close the "Android SDK and AVD Manager window" clicking on the "X" title-bar button. At this point, your Android demo is compiled and executed inside the newly created Android emulator device.

Deploy

You may run the demo against your local server or using our online server at http://push.lightstreamer.com:80. The server to which the demo will connect to is configured in the res/values/strings.xml file. In the former case, the example requires that the QUOTE_ADAPTER has 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 Android Client API v. 1.0.2 to 1.2.

About

This project contains a full example of a Java application that employs the Lightstreamer Android Client library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages