Category Archives: Android

Mobile Development

I’ve been excited for the past year or so about RubyMotion, and I was even more excited when they announced support for Android.

Then I went to WWDC.

I already felt like PhoneGap was too much of a disconnect.  Mobile web and PhoneGap are good in a pinch, and there are things that are more easily done in a web form.  However, I’ve had a growing feeling that if you have the ability to make a native app then that is the right answer.  Anything short of making a native app is a shortcut that you’ll eventually regret.

You already don’t control the ecosystem, but if you’re depending on someone’s abstraction of the native implementation then you’re one step removed from the metal.  More importantly, being as close as possible to the metal gives you a more intimate feel for the nuances of that platform.

iOS 8 doesn’t look all that different compared to the bold new look of iOS 7.  But everything is different.  Just slightly enhanced or extended.  Apps can work together seamlessly.  User interfaces are adaptive.  Everything changes, but ever so slightly.

If you’re not right up against that cutting edge, then how can you fully take advantage of everything the operating system gives you?

Leave a Comment

Filed under Android, iOS, programming

Android vs Google Glass LocationManager

I’ve played around with location a lot in the past year at Sabre Labs, and also in my previous job at Geoforce.  I find it very interesting and fun to work with.  Recently in The Lab we took on a Google Glass project.  The Glass is an interesting animal.  It runs Android, but it’s ever so slightly different.   One area that tripped me up was location.

So, here is a comparison of LocationManager in Android vs LocationManager in Google Glass.

Android:


// Android-flavored location
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 35000, 10, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 35000, 10, this);
Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, false);

Google Glass:


// Google Glass-flavored location
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
List<String> providers = locationManager.getProviders(criteria, true);
for (String provider : providers) {
    Log.d(TAG, provider);
    location = locationManager.getLastKnownLocation(provider);
    if (location != null) {
        this.onLocationChanged(location);
        // one location is probably sufficient
        break;
    } else {
        // probably don't need regular updates, but if we miss a last known location we might
        locationManager.requestLocationUpdates(provider, 35000, 10, this);
    }
}

You’ll note that there is an extra context. before the getSystemService call in the Glass example. That’s because I put the LocationManager in a separate singleton class, so I get the app’s context first.

I wanted to have a lot of utility classes off the main UI thread, and I only needed location to support a subset of API calls that I fire off to our service. HTTP requests have to be done asynchronously, so I had a good clean line of delineation between the view layer and object models.

Leave a Comment

Filed under Android, programming