Checklist: Build Android Clients Using Kaazing WebSocket Gateway

The following checklist provides the steps necessary to build clients to communicate with Kaazing WebSocket Gateway:

# Step Topic of Reference
1 Learn about supported browsers, operating systems, and platform versions. Release Notes
2 Use the WebSocket API provided by the Kaazing Android client library to take advantage of the HTML5 WebSocket standard. Use the Kaazing WebSocket Gateway Android Client API
3 Learn how to authenticate your Android client with the Gateway. Secure Your Java and Android Clients
4 Set up logging for your client. Display Logs for the Android Client
Notes:
  • For information about the Kaazing WebSocket Gateway Android Client API, see Android Client API.
  • Java Developer Kit (JDK) or Java Runtime Environment (JRE) 1.6 and above are required.

WebSocket and Android

Android is an operating system used by touchscreen smart phones and tablets. Android clients are developed in the Java programming language using the Android software development kit (SDK). The SDK includes development tools, software libraries, and an Android device emulator.

The officially supported integrated development environment (IDE) for Android development by Google is Eclipse using the Android Development Tools (ADT) plugin. To develop Android clients, download the ADT Bundle that includes both Eclipse and the ADT plugin.

Kaazing WebSocket Gateway provides an Android Client API to enable HTML5 WebSocket protocol communication in new or existing Android applications. For example, you can create an Android client to get streaming financial data from a back-end server using WebSocket. The following figure shows a high-level overview of the architecture:

Figure: Enable Communication Between Your Android Client and a Back-end Server over WebSocket

Android and Server-Sent Events (SSE)

Kaazing WebSocket Gateway Android Client API also provides support for Server-Sent Events (SSE). For information, see the Android SSE API and Java Client API topic Interact with Kaazing WebSocket Gateway Using the EventSource API.

Take a Look at the Android Client Demo

Before you start, take a look at an out of the box demo built using the Android Client API. The Android demo is part of the Kaazing WebSocket Gateway bundle (GATEWAY_HOME/demo/android/kaazing-android-demo). To see this Android demo in action, perform the following steps:

  1. Download the Android ADT Bundle from http://developer.android.com/sdk/index.html. The Android ADT Bundle includes the Eclipse IDE. To use the Android SDK with an existing Eclipse IDE, see http://developer.android.com/sdk/installing/index.html
  2. To set up the ADT Bundle, see http://developer.android.com/sdk/installing/bundle.html.
  3. Launch Eclipse from the installed ADT Bundle.
  4. In Eclipse, click Window, and then click Android SDK Manager.
    1. Select any package from Android 2.3.3 or later and then click Install package. Once the packages are installed, continue to the next step.
  5. In the Eclipse Package Explorer, right-click an empty area and select Import.
  6. Expand the Android folder and click Existing Android Code Into Workspace, and then click Next.
  7. In Import Projects, for Root Directory, click Browse.
  8. Navigate to the Android Demo project files: GATEWAY_HOME/demo/android/echo-demo
  9. Click Open.
  10. In Import Projects, click Select All (to select the EchoActivity project), select Copy projects into workspace, and then click Finish. The Android Demo is added to Eclipse.
  11. Create a new Android Virtual Device in Eclipse.
    1. In Eclipse, from the Window menu, click Android Virtual Device Manager.
    2. In the Android Virtual Device Manager, click New.
    3. Enter a name for your new virtual device in AVD Name (in this example, AndroidTablet).
    4. In Device, select Galaxy Nexus.
    5. In Target, select Android 4.2.2 - API Level 17.
    6. In Keyboard, ensure Hardware Keyboard present is selected and click OK.
    7. Click Create AVD. The new virtual device is listed in the Android Virtual Device Manager.
    8. Select the new virtual device and click Start. The Android emulator launches. You can close the AVD Manager dialog in Eclipse.
  12. In Eclipse, right-click the EchoActivity project in Package Explorer, select Run As, and then click Android Application. The Android emulator launches.
    Figure: Android Emulator Running the Echo Demo
  13. If the following location is not already listed in the Location field, enter it: ws://echo.websocket.org
  14. Click Connect. The messages CONNECTING and then CONNECTED appear. The WebSocket connection to the Gateway was successful.
  15. Click Send. The message Hello World! is sent to the Echo service over WebSocket and the message is echoed back as Hello World!.
  16. Click the Send Binary checkbox and click Send again. The message Hello World! is sent to the Echo service over WebSocket as binary and is echoed back as:
    RECEIVED: 48 65 6c 6c 6f 2c 20 57 65 62 53 6f 63 6b 65 74 21
    SEND BINARY: 48 65 6c 6c 6f 2c 20 57 65 62 53 6f 63 6b 65 74 21
  17. To test the Android client on an Android device, ensure USB debugging is enabled on your Android device (Settings > Applications > Development), and plug the device into your system.
  18. In Eclipse, right-click the EchoActivity project, select Run As, and then click Android Application. The Android client is deployed to your Android device. Follow the location, connection and send steps to test the client on your device.

See Also

Android Client API

TOP