Nowadays, wearable devices are one of the hot topics of technology. Google just released its Android Wear SDK and Google Glass is becoming more common in daily life. Until November 2013, only the developers that have Google glass device could develop applications for glass. But after November 2013 Google opened Mirror API for all developers.
You have two options to develop for glass:
- Mirror API:The Google Mirror API allows you to build web-based services, called Glassware, that interact with Google Glass. It provides this functionality over a cloud-based API and does not require running code on Glass.
- With Mirror API, you can;
- Managing timeline cards
- Interacting with menu items
- Subscribing to timeline notifications
- Sharing to contacts
- Working with user location
- Glass Development Kit: The Glass Development Kit (GDK) is an add-on to the Android SDK that lets you build Glassware that runs directly on Glass.
Ps: Our demo application was developed by Mirror API, so rest of the blog is about Mirror API.
To develop applications on glass with Mirror API, Google serves us different libraries for.Net, Java, Javascript, Objective-C, Php, Python, Ruby, Dart, Go. if you need you can look into samples for each library.
Run Google Glass application on SAP Hana Cloud platform
Prerequisites:
Ps: I strongly recommend to you follow openSAP courses of Thomas Jung and Rui Nogueira about Hana Topic
In this blog scope we will use Java Quick Start Demo of Google. Google also serves demo projects in other platforms, i chose Java platform because Hana cloud platform can run java applications. I modified original demo to run on Hana Cloud Platform. In original demo project, Google uses Apache Maven to manage package dependencies. To prevent you fighting with packages, i export my modified demo in war file, so i suggest you to use attached war file.
At the end of the operations we will deploy demo to Hana Cloud Platform. Then users will authorize via created url on cloud platform. After successful login, current timestamp, name and location of user are saved to Hana Database and a timelinecard is posted with the last logged in users data.
Deploy Quick Start Demo: There is two major task to deploy demo - Creating a Google APIs Console project:
Google has a detail tutorial to create a console project. You can follow the instructions. The created client ID and client secret for my project:
- Importing project to hana studio
Download attached .war file and import project into Hana studio. (If you want to try Quick start demo independently from Hana studio, please download .zip file, import it as archieve project into eclipse)
If everything is OK Then; - Open “oauth.properties” file under “com.google.glassware” package and copy your client_id & client_secret values that were created in Google Api Console project.
- Set Context Root to “/” from project->properties->”Web Project settings” (after login, google redirect you to project root, i don’t want to change original project so leave like this)
- If needed, change java version from project->properties->”Project Facets” (application is running smoothly with java 1.6 or 1.7)
- if you using eclipse instead of Hana Studio install m2e in eclipse and be sure Maven library is setted from project->properties->”Deployment Assembly”
The modifications & new developments over original demo project; - For new developed classes, com.hana package was created
- UserInfo class was created, to get&keep user login info
- HanaMirrorClient class was created, to post timelinecard on glass
- UserDAO class was created, to manage Hana database operations (jdbc was used)
- “Append Hana Log” button was added into index.jsp file
- to get user info, UserInfo instance was created in index.jsp file
- To post a new timelinecard as soon as user login, NewUserBootstrapper class was modified
After all the last operation is deploying project. To deploy on Sap Hana Cloud, in hana studio go to servers section, add a new Hana Cloud Portal Server and run your project on hana server.(For this step, You can find detail instructions on Rui Nogueira openSap videos). Ps:If you run project in eclipse, Download Tomcat(version is very important I tried with Tomcat7.0.52), add it as a new server in eclipse and run your project on Tomcat Server.
Test Your Project: Open Hana Cloud cockpit and go to your deployed application details. There is a url to run your application. You can run my application viahttps://hanaonglass1p104935trial.hanatrial.ondemand.com to post yourself a timelinecard.
If you wonder how timelinecard will look on google glass device, you can use google playground application via https://developers.google.com/glass/tools-downloads/playground . In order to use the Playground with the Google Mirror API, you need to insert your project's client ID. To test my application paste "236007231554.apps.googleusercontent.com" to textbox and click authorize.
I’m living in Turkey and Google Glass hasn’t sold here yet. So i should say that i couldn’t try application on device. If someone who has glass maybe try application on device, and we will be very glad with feedbacks.
Update: (01.05.2014) Thanks a lot to Randy Middleton. He run demo on glass and send screenshots to us. Now we are sure that demo is working on device smoothly(Google Glass Explored XE16.11 - XE16.2). Nice collaboration in SCN Community !! Update2: (29.08.2014) Thanks a lot to Markus Van Kempen. He deployed the code to his own trial cloud account. Now we are sure that attached code can be deployed without defect and it is working on device with version XE 20.1 flawlessly.
|