Google’s attempt to get into augmented reality has proved to be most successful so far, in comparison to other providers of smart glasses technology. Even though Google Glass is not yet ready for the mass market, its beta version has already attracted a great number of people with innovative views, including some of our customers. Geolocation is one of the most useful features that you can implement using Google Glass.

Two ways to implement geolocation

There is no way a user can access geolocation on Google Glass if the device is not connected to a smartphone, either iPhone or Android because there is no GPS inside Google Glass. If you have questions about how geolocation technology exactly works and how to create a location-aware app, read first this post:

That’s why we decided to investigate how to implement geolocation using your smartphone and a buzzed Google’s device. We are going to look at the two ways of doing that. They are:

  • GDK (Glass Development Kit, native)
  • Mirror API (Cloud-based service)

Implementing geolocation on Glass with GDK is similar to that on regular Android devices. It implies using standard APIs for the Android platform to get location data from available location providers. With GDK you can access location data anytime, and with the interval you need.

On the other hand, when you’re developing glassware using Mirror API, your cloud-based app has very limited access to location data. Glass sends location data to MirrorAPI once in 10 minutes. Then, if your app is subscribed to the user’s location updates, it will receive a callback with location data from MirrorAPI. Also, you can request the last known user location data in the same way. Now let’s take a closer look at each method.


The Glass Development Kit (GDK) is an add-on to the Android SDK that lets you build Glassware that runs directly on Glass. You should use the following Android SDK classes to get location data:

  • LocationManager – Provides access to Android location service which handles communication with LocationProvider.
  • LocationProvider – Glass provides special “remote” location data sources. They let you get access to data from a paired device that has a MyGlass companion app installed.
  • Criteria – It’s a condition under which location data can be considered accurate. You need to create a set of criteria to be able to choose the most fitting location data from the data source.

You would need to use the LocationManager class to get the data from one or more location providers.

Android apps retrieve location data from local GPS and mobile networks. On Glass, however, a set of available location providers is dynamic and may include remote ones. They supply location data from another source, such as Bluetooth enabled devices paired with the MyGlass companion app. To handle these additional providers, subscribe to location updates from multiple providers, rather than a single one.

Note: Subscription to location updates doesn’t imply using LocationManager.getBestProvider() method or the constants GPS_PROVIDER or NETWORK_PROVIDER. Glass uses a dynamic set of providers. Thus, if you subscribe to a single provider only, your app might miss location updates.

To request data from all available location providers:

  • Create a Criteria object with your location requirements.
  • Call getProviders() to retrieve the list of providers that satisfy your criteria.
  • Iterate over the list of providers and request updates from all of them. This will not only allow you to receive updates from available remote providers, but also from the local ones, which communicate with Glass (e.g. through a wireless network provider).
  • Pay attention to the accuracy of the timing information provided with each update to determine whether the current update is correct or if you should wait for another one.

Here is an example of how to choose location data source and request updates:

LocationManager locationManager; // initialized elsewhere

// This example requests fine accuracy and requires altitude, but

// these criteria could be whatever you want.

Criteria criteria = new Criteria();



List<String> providers = locationManager.getProviders(

criteria, true /* enabledOnly */);

for (String provider : providers) {

locationManager.requestLocationUpdates(provider, minTime,

minDistance, listener);


A full example of how to implement geolocation on Glass.

How to Implement Geolocation in Google Glass

Using directions app in Glass

Glass has a pre-installed app that lets you build routes and use navigation. In order to launch it, you should send an Intent to the system: Action: ACTION_VIEW

Data URI Scheme:


1. ll – Location coordinates. There is no need to specify a query if you have specified the coordinates.

2. title – The name of the place displayed. It will show you the latitude and longitude of the location by default (in case you specified those properties). Otherwise, it will display the name of the location (in case you specified a query).

3. query – A string to query for places you need to build a route to. Do not specify ll if you specify this.

4. mode – Defaults to MRU (most recently used) if not specified or “d” if MRU does not exist. Possible values are:

d – Driving

w – Walking

b – Bicycle

r – Transit

MRU – Most Recently Used.


Intent navIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(“google.navigation:ll=37.4219795, -122.0836669&title=Belvedere Ln”));

Google Glass. Geolocation

As you see using GDK is pretty simple. Here is an example of geolocation-enabled glassware I wrote using GDK. So let’s move further and see the possibilities of Mirror API.

Mirror API

Google Mirror API allows you to build web-based services that interact with Google Glass. It provides this functionality over a cloud-based API and does not require running code on Glass. You have the following possibilities if work with the location in MirrorAPI:

  • You can request the user’s last known location
  • You can subscribe to periodic location updates
  • You can render a map on timeline cards

Note: Glass device sends location data to the cloud every 10 minutes. All location updates will be received by your server-side. Firstly, you should request additional permission scope to acquire user location during the OAuth 2.0 authentication process: scope

Then you should call the “subscribe” method from Google Mirror API and provide the URL which will receive location updates.

To retrieve the last user’s location:

Send a GET request to the REST endpoint:

GET /mirror/v1/locations/ HTTP/1.1

Authorization: Bearer {auth token}

You will receive the following JSON response.


“kind”: “mirror#location”,

“id”: string,

“timestamp”: datetime,

“latitude”: double,

“longitude”: double,

“accuracy”: double,

“displayName”: string,

“address”: string


Using this query you’ll receive the last known user location and its timestamp. To subscribe to user events: Send POST request to the REST endpoint:

POST /mirror/v1/subscriptions HTTP/1.1

Authorization: Bearer {auth token}

Content-Type: application/json

Content-Length: {length}

{“collection”: “locations”, “userToken”: “harold_penguin”, “verifyToken”: “random_hash_to_verify_referer”, “callbackUrl”: “”}

Response is similar to that when you request the last known location.

Note: callbackUrl should ALWAYS be https

To render the map on the timeline card sent from the server:

Google Mirror API can render maps for you and overlay markers and lines to identify important places and paths. Use the glass://map URI to request a map. Here’s an example:

<img src=”glass://map?w=width&h=height&marker=0;latitude,longitude&marker=1;latitude,longitude&polyline=;latitude,longitude,latitude,longitude”



Here is a description of the required parameters: w – The width in pixels of the returned map image h – The height in pixels of the returned map image


As you can see MirrorAPI isn’t perfect for apps where you need to get the data immediately since the location data gets updated every 10 minutes. However, you can apply this method for other purposes, such as targeted content (pinned to the location). For example, you can send a card with current films to the user’s timeline right when she is walking near the cinema.

In conclusion, operating with MirrorAPI and GDK doesn’t cause any difficulty. If you would like to know more about technical particularities of implementing geolocation on Google Glass, as well as some advice about which method will work best for your app, you are welcome to send us a note!