Tag Archives: google glass

Google Glass Development Kit Sneak Peek Revision 2 – List of Some API Changes

I came across lots of problems when the glass updated to XE12, long ago. Today I found out this article which I thought I would like to share with you all.

My Glass was automatically updated with the monthly update XE12. This update included a new version of GDK implementation, known as Sneak Peek Rev. 2.

Since the update, I could not run any of my GDK sample apps. I was getting errors like: java.lang.NoSuchMethodError: com.google.android.glass.timeline.TimelineManager.getLiveCard.

As it turned out, this new GDK revision included some non-backward compatible API changes. Clearly, names like “Sneak Peak” or “Preview” edition imply they are not stable releases, and APIs can change any time. But, I was caught a bit off-guard, and a bit disappointed since it happened “without warnings”. (Or, maybe there was a pre-announcement, and I may have missed it because I’m off-line most of the time these days.) I mentioned the importance of “backward compatibility” in software engineering a few times before. Even more importantly, I believe that software engineers should strive for “forward compatibility”. This is a difficult goal to attain because, in many cases, developers do not know what product features they will need to support in the future. In most organizations, they come down from “PM’s” or people from “higher up”. Nonetheless, I think it is possible, and it is worth pursuing.

Anyways, I went through all my sample apps on GDK Demo and updated the code based on the new API. I’ll include the list of API changes here. This is only a partial list since the GDK Demo apps use only a subset of the GDK APIs.

First, you’ll need to update your GDK using Android SDK Manager. Since the original GDK release about a month ago, there seems to have been no other Android updates. When I opened the SDK Manager last night, it found only one update, GDK rev. 2. You can copy the updated gdk.jar file into your project dir and include it in your build path, or you can just set your compileSdkVersion to a GDK-specific string. I personally prefer the first approach because there are some benefits of using a higher version for compileSdkVersion than that of targetSdkVersion (which should be 15 at this point). If you plan to do any “cross-platform” development (e.g., your app targeting both Android phones and Google Glass), then you probably have no choice but to use the Jar file.

So, here’s the list of API changes in GDK (as relevant to the currently “released” GDK Demo apps).

  • TimelineManager: Method name change from getLiveCard(cardId) to createLiveCard(cardTag). (I’m only presuming that these are the same method, and the API change entails only the name change.)
  • LiveCard: It appears that the method setNonSilent(boolean) has been removed. Instead, this “nonsllent” flag is set during publishing. The signature of the method publish() with setNonSilent(true) has been changed to publish(LiveCard.PublishMode.REVEAL). If you used setNonSilent(false) for your livecard, then you now need to call publish(LiveCard.PublishMode.SILENT) instead.
  • LiveCard.enableDirectRendering(boolean) has been changed to setDirectRenderingEnabled(boolean).
  • com.google.android.glass.media.Camera has been, it appears, renamed to CameraManager.
  • The surface rendering callback interface, LiveCardCallback seems to have been renamed as DirectRenderingCallback. My existing code just compiled fine (haven’t tried running them all though) after only changing the interface name.

That’s about it. Again, this is only a partial list of API changes in the new “Revision 2” version of GDK (as relevant to the “GDK Demo” sample Glassware). I haven’t done any comprehensive comparison of old vs. new GDK jar files or anything like that (which is probably easy to do). Google might have posted some kind of “release note” or “change log” at this point (which I haven’t seen yet though).

Meanwhile, I hope other GDK developers find my list useful, for now.

PS 1: BTW, interface name changes like LiveCardCallback -> DirectRenderingCallback possibly imply that there might be something coming in the future that are in some way equivalent/similar to LiveCard (maybe, DeadCard? :)). This is known as “breaking backward compatibility for forward compatibility”. We developers do this all the time, whether we realize it or not. We create, say, a class for certain purpose (with a certain name), and later realize that we have chosen too specific a name because the class can be more broadly applicable than initially planned.

Reference – http://blog.glassdiary.com/post/70419002255/google-glass-development-kit-sneak-peek-revision-2

Link to the GDK Release note – The GDK release note page.

Advertisements

What comes with the new Google GLASS Development Kit?

The GDK is an Android SDK add-on that contains APIs for Glass-specific features.
sdk-gdk

Unlike the Mirror API, Glassware built with the GDK runs on Glass itself, allowing access to low-level hardware features.

At the time of writing this article Sample GDK has been released out introducing ways to develop native android apps for Google Glass.

gdk-glassware-android

So what does the new GDK brings

1. A new platform for you to develop your GLASS apps so it will have special libraries needed to for the Google GLASS. Not all are available yet, you have to wait for the final version to come.

2.Touch Gestures – Accessing raw data from the Glass touchpad is possible with the Android SDK. However, the GDK provides a gesture detector designed for the Glass touchpad that automatically detects common gestures on Glass, including tapping, swiping, and scrolling. Click Here for detailed info on developing

3.Voice Input – Voice is an integral part in a hands-free experience for users. Glass lets you declare voice triggers to launch your Glassware from the ok glass voice menu. Click Here for detailed info on developing

4.Location and Sensors – You access location and sensor data using the standard Android platform APIs. You have to access the paired device for location and there is another way of gettin location without the help of paired device. It is taken based on the Wifi hotspot, but it wont be accurate as much as the location taken fron the paired device’s gps. Click Here for detailed info on developing

5.Camera – You can use the Glass camera to capture images and video and to also display the camera’s preview stream for a variety of different use cases. Click Here for detailed info on developing

Reference : Site Name – Glass Development KIT, Url – https://developers.google.com/glass/develop/gdk/index, Date 5th December 2013, Time – 12.13pm (GMT +5.30)

Google Glass – Adding your Own Voice Commands to Your Apps

Hey guys with the introduction of the Glass development Sneak Peek, I found the way to add your own voice command to trigger your app. This is for native Android Apps.

What you have to do is,

Step 1
inside the manifest file add these tags under the service which you wanted to trigger on your voice command.

<intent-filter>
<action android:name=”com.google.android.glass.action.VOICE_TRIGGER” />
</intent-filter>
<meta-data
android:name=”com.google.android.glass.VoiceTrigger”
android:resource=”@xml/voice_trigger_start” />

Step 2And you have to create a folder called xml inside res and add a xml file named as “voice_trigger_start.xml”

Step 3
Inside that add these lines

<?xml version=”1.0″ encoding=”utf-8″?>

<trigger keyword=”@string/its_me_amalan” />

Step 4
Open the values folder inside res folder and edit strings.xml, so it will look like this

<resources>
<string name=”app_name”>Amalan</string>
<string name=”its_me_amalan”>Hello Amalan</string>
<string name=”stop”>Stop</string>
</resources>

Now install the app into the google glass and say
OK GLASS Hello Amalan
And the app opens

I have used my name 😉 but you can try lots of other words.

Please install the latest  Glass Development KIT and tryout the samples, you can get more out of it 🙂

Get the Source here
gitHub-download-button

 

Google Glass in Colombo Agile Meetup…!

1st of October 2013 at Voice Lounge, Burgher Recreation Club, Colombo Agile Meetup hosted one of their most wanted meetups featuring the famous Google Glass. So the topic is “A real life case study of a Google glass project.”

20130912_143933

Shamira Dias (Delivery Manager, Exilesoft), started the talk, with the Subject “Unfamiliar territory and uncertain outcomes: The Google Glass Project”. So he elaborated the types of projects that Exilesoft do, and how the developers here at office and onsite, deal with it. Sometimes they are not familiar with the business domain, but holding back is not the prudent thing to do. Therefore, to add to it, when a project appears with an unfamiliar object he explained using the Google Glass project which they are currently working on in Exilesoft, how agile practice helped them, and how they co op-ed and won, in the end.

1381930_10151585171006710_1273619941_n

Next the talk was passed onto Sanath Nandasiri (Software Engineer, Exilesoft) one of the two developers, directly connected with the ongoing Google Glass project (the other one is Me ). He explained what Google Glass is, what it has, what it can do and available features on it.  So the session went with some live Google Glass Demo, which really entertained the audience. One of the important features I thought was, it runs Android 4.0.4 and it got a wonderful natural voice recognition which has a high accuracy rate.

556621_10151585171726710_2012012341_n

Further on Sanath moved into Google Glass development. There are 2 ways that we can approach the GLASS development. They are the native way (Android) and the Glassware development (Server Side using Mirror API). Then he explained how the glassware works, what the role of the Mirror API is and the technologies used to develop a glassware. Native development is similar to the traditional android development but with some restriction of functionality and libraries. One of the reason for the restriction is caused by the lack of sensors in Google GLASS unlike normal Android phone. Those functions can be achieved by pairing to your Android phone through Bluetooth. Also explained how the glassware authentication take place under the hood.

Then another round of demo session took place explaining the Google GLASS Time line. And a cool thing happened for developers, there has been a code review on Glassware and the code has been open sourced. The source can be downloaded here. Also as a bonus, Sanath explained and showed how you can bring in Google Glass in your Android phone that is running Android 4.0.4 or later, this will be a great emulator to test your Glassware apps (It cannot be used to test native apps though).

Finally Dulan Bandara (Software Engineer, Exilesoft), explained about unit testing and its importance in the Glass Project. Then he compared unit test on Android and unit testing on Google Glass. There was a hands on coding demo for the unit testing. It’s important to mention that a bunch of visitors got a chance to try out the Google Glass. They were awed at the experience they got.

63626_10151585172331710_1821980851_n

The talk came to an end with the Introduction of a new meet up group “Colombo Mobile Meetup”, and an Announcement of the upcoming DevDay 2013.

For the complete collection of research and development article on Google Glass explore my Blog.

Meetup Organized by Exilesoft (Pvt) Ltd.

Stream You Tube Video, in Google Glass Time Line Card, using Mirror API(C#.net)

Ok guys today we will see how we can stream a Youtube video inside a google glass timeline card.  First you need to add reference to the “YoutubeExtractor” namespace. You can get it from the nuget if you dont have it.

using YoutubeExtractor;

Now add the youtube video url to atring(The url you got when you clicked the share button not the page url).
Resolve the url and get the links for the available videos.
Select the video you wanted to stream and get the stream url.

string link = "http://youtu.be/9uYKISlL7Vg";
IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link);
VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);
String vLink = video.DownloadUrl;

Now create the timeline card and add the menu item

TimelineItem yotubeVideo = new TimelineItem()
{
Text = "Youtube Video",
BundleId = "8081",
MenuItems = new List<MenuItem>() { { new MenuItem() { Action = "DELETE" } } },
Notification = new NotificationConfig() { Level = "DEFAULT" }
};

Create a stream using the link we got, create a http request, buffer it and insert the card mentionng the video type.

String videoLink = vLink;

if (!String.IsNullOrEmpty(videoLink))
{
Stream stream = null;
if (videoLink.StartsWith("/"))
{
stream = new StreamReader(controller.Server.MapPath(videoLink)).BaseStream;
}
else
{
HttpWebRequest request = WebRequest.Create(videoLink) as HttpWebRequest;

request.UseDefaultCredentials = false;

HttpWebResponse response = request.GetResponse() as HttpWebResponse;

byte[] b = null;
using (Stream streamFromWeb = response.GetResponseStream())
using (MemoryStream ms = new MemoryStream())
{
int count = 0;
do
{
byte[] buf = new byte[1024];
count = streamFromWeb.Read(buf, 0, 1024);
ms.Write(buf, 0, count);
} while (streamFromWeb.CanRead && count > 0);
b = ms.ToArray();

stream = new MemoryStream(b);
}
}
controller.Service.Timeline.Insert(yotubeVideo, stream, "video/mp4").Upload();

Now the stream will work like a charm

Adding a time line card using Mirror API, that can make call from Google Glass (C#.net)

To call a person you need contact details of a person so we will create a contact first.

Contact Amalan = new Contact();
Amalan.PhoneNumber = "+940711111111";

Now create a Timeline card and add call function on the menu item of the  card. When create the timeline card add the contact we created as the Creator

TimelineItem contactNumber = new TimelineItem()
{

Text = "Call Amalan",
BundleId = "8081",
Creator = Amalan,
MenuItems = new List<MenuItem>() {
new MenuItem() {Action = "VOICE_CALL"},
new MenuItem() {Action = "DELETE"}},
Notification = new NotificationConfig() { Level = "DEFAULT" },

};

Now we will insert the card that we created

controller.Service.Timeline.Insert(contactNumber).Fetch();

That’s it now you can make the call using the timeline card. Don’t forget to pair your phone with the GLASS

Insert Video in, Google Glass Time Line Cards, using Mirror API(C#.net)

private static String InsertVideo(MainController controller)
{

TimelineItem critical = new TimelineItem()
{

//Text = "Third Card",
BundleId = "346",
//IsBundleCover=true,
//Html = "<article class=\"photo\">\n  <img src=\"http://www.youtube.com/watch?v=suz446-BOHg\" width=\"100%\" height=\"100%\">\n  <div class=\"photo-overlay\"/>\n  <section>\n    <p class=\"text-auto-size\">Third Card</p>\n  </section>\n</article>",
//Attachments = new List<Attachment>() {new Attachment(){ContentUrl="http://www.youtube.com/watch?v=suz446-BOHg"}},
//MenuItems = menu,
Notification = new NotificationConfig() { Level = "DEFAULT" },
MenuItems = new List<MenuItem>()
{
new MenuItem() {Action = "NAVIGATE"},
new MenuItem() {Action = "DELETE"},
new MenuItem() {Action = "SHARE"},
}
// Locaton = location.Latitude
//bundleId = 10001;
};

String mediaLink = "your video link as text here";

if (!String.IsNullOrEmpty(mediaLink))
{
Stream stream = null;
if (mediaLink.StartsWith("/"))
{
stream = new StreamReader(controller.Server.MapPath(mediaLink)).BaseStream;
}
else
{
HttpWebRequest request = WebRequest.Create(mediaLink) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;

byte[] b = null;
using (Stream streamFromWeb = response.GetResponseStream())
using (MemoryStream ms = new MemoryStream())
{
int count = 0;
do
{
byte[] buf = new byte[1024];
count = streamFromWeb.Read(buf, 0, 1024);
ms.Write(buf, 0, count);
} while (streamFromWeb.CanRead && count > 0);
b = ms.ToArray();

stream = new MemoryStream(b);
}
}
controller.Service.Timeline.Insert(critical, stream, "video/mp4").Upload();
}
else
{
controller.Service.Timeline.Insert(critical).Fetch();
//controller.Service.Timeline.Update

}

return "A timeline item has been inserted.";

}

Credit goes to Sanath Nandasiri