Antenna Aligner Part 9: Progress and Updates

It’s been a while since my last post, and things are going well. I’ve currently got over 260 users, and some really positive feedback! I’ve also had a few support emails what I have addressed in version 1.0.2. The most interesting issue was the behaviour of the app when the gps was not enabled. In 1.0.1.  If the gps was disabled, the app did nothing!

The call to the geolocation system in phonegap has both an error and success callback. I had handled the success callback fine (after all, that’s how the app works at all!), but the error callback just made sure the app didn’t crash! However, what it really needed to do was tell the user to switch on their gps.

I started by having an alert call in the error callback to prove that disabling the location services on my iPhone would indeed trigger it. This worked fine, the only snag was that the alert dialog box showed “index.html” in the dialog title, this was not cool, and certainly not what I wanted.

So after a bit of googling, I found out that as well as data-role=”page” there is also a data-role=”dialog”, which sounded like what I wanted.

   <div data-role=”dialog” id=”quot;locationError”” data-transition=”none”>
       <div data-role=”header”>
           <h1>GPS Error</h1>
       </div>
       <div data-role=”content”>
           <p>The GPS system is not enabled.</p>
           <p>To use Antenna Aligner, please enable the GPS in your device’s settings.</p>        
       </div>
   </div>

and this is triggered by the following code.

    $.mobile.changePage(‘#locationError’, {
               transition: ‘none’,
               reverse: false,
               changeHash: true
           });

Unfortunately, yet again I had to remove the page transitions cause they are too flaky on iOS. It’s a shame cause they look pretty cool, but I would rather the app not flicker all over the place when switching pages I suppose!
So my app now has error reporting.

Then I tried it on Android. What’s interesting on the android platform is that the gps works in 2 ways. If there is a wireless connection, the gps will use that in conjunction with the built in gps system. With the wireless switched off, the handset should default to the pure gps system.

However, when trying my app out on an Android phone with wireless disabled, it just didn’t work. The first screen stayed at “please wait” and went no further. After some investigation, I found out that I needed to explicitly set the geolocation option enableHighAccuracy to use the gps without wireless.

               var geolocationOptions = { enableHighAccuracy: true };

It also turns out that the effectiveness of this facility will vary depending on the handset. My wife’s galaxy S with wireless and data disabled managed to get a GPS fix within seconds, whereas my test handset, a desire S, took considerably longer (minutes!). However, I’m hoping that most people will have at least a data connection so it should work fine… only one way to find out I suppose!

Next time: Releasing the Android version! (hopefully)