Channels ▼


Hacking for Fun: Programming a Wearable Android Device

I declared the latitude and longitude variables as public so I could access the values from my other private methods in the MainActivity class:

public double latitude;
public double longitude;

And then set the values of them when the updateWithNewLocation event was fired:

private void updateWithNewLocation(Location location) { 
	String latLong; 
	TextView myLocation; 
	myLocation = (TextView) findViewById(;

	if(location!=null) { 
    	latitude = location.getLatitude(); 
    	longitude = location.getLongitude(); 
    	latLong = "Latitude:      " + latitude + "\nLongitude:  " + longitude;     	
	} else { 
		latLong = "Unable to obtain a GPS Location Fix"; 

I passed the latitude and longitude values as arguments into the constructed Dark Sky JSON call, along with the API key that Dark Sky issued me when I requested a developer test account, and made the call to the server via Recon's WebRequestBundle method :

WebRequestBundle wrb = new 
WebMethod.GET, "", new ArrayList<NameValuePair>());

I ran the response string received from Recon's SDKWebService onComplete method through the JSON library, parsed for the hourSummary and daySummary strings, and set the text in the appropriate TextView control:

BufferedReader in = new BufferedReader(new StringReader(response));
String line;
while ((line = in.readLine()) != null) {
	JSONArray jarray = new JSONArray("["+line+"]");

	for (int i = 0; i < jarray.length(); i++) {
		JSONObject jobject = (JSONObject) jarray.get(i);
		mNextHour.setText("Next Hour: " + jobject.getString("hourSummary"));
		mNextDay.setText("Today: " + jobject.getString("daySummary"));

The current temperature, forecast, and latitude/longitude results show up in the main window. I also remembered to disable the Android titlebar via the android:[email protected]:style/Theme.NoTitleBar.FullScreen directive in the Android Manifest file) using Recon's recommended Eurostyle 24 sp typeface (though Recon says this is being deprecated for Google's Droid Sans font in the next release) for easy reading:

    android:padding="8dp" />

I also needed to add the necessary location access permissions to the Android Manifest file:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />   

Note that I did not have to add an "android.permission.INTERNET" permission to the manifest, since Recon's WebAPI proxies through the Bluetooth connection via a pre-released developer's build of Recon's HQ Mobile application, required to run on the host's Android smartphone. This network-proxy-capable pre-release build of HQ Mobile will be made available on the Google Play marketplace once Recon has fully tested it with its development partners.

Finally, I polished off the app with its own square 245x245 pixel icon. And voilà, a new MOD Live app was born.

Running the Application

Because my Dark Sky-powered app requires an Internet connection to retrieve the latest forecast, I first had to pair the MOD Live with my Android smartphone via a Bluetooth connection. Then I had to execute Recon's MOD Live application on my phone. The app requires nearly every permission in the Android arsenal, so if you're paranoid about privacy or unauthorized data leakage, this may make you nervous. Yet unlike a lot of other apps in the Android Play store, Recon has explicitly spelled out in the application's description page which services are being used in the app and why they are necessary. Still, without the Recon app running on your phone, you will receive a "Paired but not connected" error if your phone has been associated with MOD Live via the Bluetooth connection, but you don't have the Recon MOD Live app running as a service on your phone.

Assuming these dependencies are met and you have had the MOD Live powered on long enough to obtain a GPS lock, scrolling through the icon menu and selecting the app to launch it should submit the latitude and longitude to the Dark Sky Web service and display the next hour's weather conditions on the HUD.

Figure 6: The running MODLive Dark Sky API assisted application.

Improving the Application

Time permitting, I would improve the application by iconifying the results rather than making the user read the resulting forecast text. For example, if snow was expected in 20 minutes, I would display a snowflake icon followed by the number 20. That number would count down with each passing minute.

If the user needed more forecast details, I could provide two additional screens, accessed via the right and left remote buttons. These screens would show extended forecast data such as "next three hours" and "next 24 hours," while the second detail screen would call upon national weather service maps of the area for an up-to-date precipitation snapshot.

A few more graphic accoutrements such as better icons and graphic layouts along with friendlier error trapping for network connection problems would also need to be added before considering submitting such an app to Recon for inclusion into their upcoming MOD Live online app store. And yet, the key takeaway from building an application for the MOD Live platform is how the whole user experience needs to be accounted for when building HUD-based Android applications. As the MOD Live design guidelines recommend, HUD apps should only require a split second of attention to impart the data feed to the user. Any longer than that will negatively impact the user experience.

The MOD Live Developer Experience

I have used a number of HUDs in the past, ranging from proprietary embedded OSs to ones connected to a Windows CE hip pack, and each suffered from the problem of discomfort after 10 minutes of use. This discomfort manifests itself in the form of a headache either from eyestrain, the weight of unbalanced gear strapped on the head, or both. Remarkably, Recon Instruments has alleviated these problems by keeping the HUD below eye level, intended for quick glances. By combining the HUD hardware with a comfortable pair of well-cushioned, well-balanced ski goggles, the HUD's weight is equally distributed across the goggles so that the HUD's added mass is negligible. But the fact remains that HUDs in general are still a bit intrusive and will have to be further miniaturized to enter the realm of mass consumer adoption.

Nevertheless, for very specific present-day user scenarios like traveling at high speed down a ski slope or furiously peddling through a mud-soaked BMX race track, a quick glimpse at performance data surely heightens the experience. The immediate feedback also helps correct in-flight errors and offers greater situational awareness compared to non-augmented activities.

For early adopting technology enthusiasts, the MOD Live platform today offers a far less expensive glimpse into the future of visual data field augmentation. Compared to the nebulous Google Glass early developer release that costs more than triple the price of the MOD Live (assuming you even qualify to eventually get your hands on Google's hardware), Recon Instruments offers an affordable glimpse into a post-smartphone world.

For more information about the MOD Live system, visit

Mike Riley is a blogger for Dr. Dobb’s and the author of Programming Your Home: Automate with Arduino, Android, and Your Computer (2012) from Pragmatic Programmers.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.