Google Glass app with Worklight Native API
rhralston 120000NDXT Visits (7590)
Good news! Initial testing with IBM Worklight and Google Glass looks good! Google Glass is not generally available yet, but there is a preview of the GDK available and we’ve done some initial testing with Glass to see if you can leverage some of the Worklight native capabilities from Glass.
There are several ways to write applications for Glass, one of which is to use the GDK. The GDK is an add-on to existing Android SDK and looks very much like building an existing native Android app, including an APK file for installation. For more information on building apps, including samples, check out the Glass Developers site here. http
So what does that mean for Worklight? To test this out, we created a new Worklight project and added a new native Android application to it by following the instructions here http
Next we coded up a simple adapter to test the Worklight server side of the connection, the adapter simply takes the parameter passed to it adds some text and returns it to the caller.
Next, we took the sample timer app project from Google, which is available as an Android sample project when you install the GDK as described above. Then we inserted the Worklight libraries and support files from the Worklight project, then inserted code into the sample to connect to the Worklight server and make the adapter procedure call.
In the file TimerView.java, add a variable to hold the Worklight client instance:
Add 2 lines to the constructor to create the Worklight client object and connect to the Worklight Server, as you would do for any Worklight native app.
Add a line to the updateText method to call a method when the timer has expired.
Add the following method to the TimerView class to call the Worklight Adapter procedure.
Next, connect the Glass with the USB cable and make sure you see the glass with DDMS. Then you can run the application on the glass, set a timer and then start the timer.
When the application is launched on Glass, you see in LogCat that the TimerView constructor was called and the glass app connected to the Worklight Server.
Once the timer reaches "0", the updateText method is called and the Worklight adapter is called.
Here is the LogCat entry with the client request.
Here is the adapter's log output to show that the adapter received the call.
This is just a simple example, but shows that a Google Glass GDK application can run with the Worklight API libraries and use the adapters to make calls to back end services.
Applications in this model can leverage Worklight benefits like easy integration with the backend systems, securing the enterprise data and the application and making these initiatives a better investement for the enterprise, leading innovation in a scalable way.