Tag Archives: 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)

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

Google Glass and It’s Battery Consumption

Ok, developing apps and glassware for Google Glass seems to be not a big deal……!
But there are some hidden issues we have to take care of…!

GoogleGlass_1

1st one is Battery and the 2nd one is Performance…!

Even though the Google said the Battery will last for 1 Day, I could not experience the glass battery as long as that, unless it was left to sleep. When the Battery was full, I started taking a video, I got warning in 20 minutes saying battery is low, that’s it, I have to stop taking video and shutdown the glass. Here is the Video Taken.

So you must have understood, how poor the battery life is in Google Glass. So running a native Android is really a battery draining factor, specially pairing to phone through Bluetooth. And if you are using any sensors in the glass then that will cause heavy battery usage.

Alternatively we can do something like, keeping down the brightness of the display, and put the glass to sleep at most of the time(When app is idle). Avoid doing heavy process in the glass by sending the data to a server and process it and get the result.

I have read some people’s review say, using Glassware can solve the battery problem. Yes, as it is a plain html card which does not java script it won’t drain much battery.

But anyway the cards are shown in web browser objects. Smart phone users know the battery drain very much when they use web browser. So If the glassware results are going to be  shown in a series of web browser object which is called time line won’t it be draining battery very much? This point is just a conceptual thinking of mine.

Even though we have discussed only some facts about battery, there are more hidden battery factors too. But some leaked patent doc shows possible 2 side battery increasing the battery capacity by double.

One of my friends suggested a tip and it is using external battery w/USB
Here is the picture of it. You can try this too if you want more battery power. Further he mentioned that it lasts for the whole day. If you like follow him on twitter for more tips
BVfIq94IEAAZP3B.jpg large

That’s all for today, catch you guys soon with more on Google Glass…!

Google Glass Consumer Vesion Sneak Peek

Screen Shot 2013-09-15 at 7.22.51 PM

So here we can see that the google glass can be rotated up/down and left/right, where in Explorer Edition only left/right is possible. This is one of the most wanted features by the glass users.

Screen Shot 2013-09-15 at 7.21.52 PM

So in the above picture we can see that the battery will be placed on both sides for more battery, where in Explorer edition we got only battery on right side. This really increases the usage time of glass.

Screen Shot 2013-09-15 at 7.21.42 PM

In this picture you can see the glass can be moved forward and backward to adjust the view.

So with some of these features we can predict that, a adjustable user friendly device,
a device with more battery for extended usage and heavy usage.
With all these features we can we can hopefully fix a custom glass as wanted.

These are just the things known for now, but there are still, 7 or eight pages to be relieved.
So keep you eyes open , ill be updating more soon.

Image Resource  from +Isabelle Olsson(Googler)‘s Gplus post, about recent patent on Google Glass (published on September 12th).