Fun with AIR on Android – Geolocation

There are a lot of things that make building apps for mobile devices extremely fun and addictive.  I’ve especially had fun with the onboard GPS in my Google Nexus One using ActionScript (flash.sensors.Geolocation class).  It’s actually very simple.  Here’s a trivial example:

if(Geolocation.isSupported) 
{
	geo = new Geolocation();
	geo.addEventListener(GeolocationEvent.UPDATE,geoUpdate);
	geo.setRequestedUpdateInterval(10000); // update my location every 10 seconds
}
...
...
private function geoUpdate(g:GeolocationEvent):void
{
	// everything you need about the location is in the passed event
	// g.latitude, g.longitude, g.speed, etc.
}

I’m currently playing around with a mobile app that polls my location every few minutes and uses a RemoteObject to send it to a ColdFusion CFC on my server. The server saves the location data in a local database and publishes the location on a data services message queue. I then use a simple Flex app utilizing the Google 3D Maps API to visualize both my recent location history and update in real-time with any new location transmissions:
       

I’m going to add some code soon to log the location data to a on-device SQLite database when there is no network connectivity (probably using the fault event handler of the RemoteObject) and re-attempt on the next poll.

Once I’m done with the app, I’ll post the full client and server source code.

Resources:

~ by gregorywilson on May 26, 2010.

6 Responses to “Fun with AIR on Android – Geolocation”

  1. it reminds me of the family circus if I am understanding it right, you will have a trail behind you, like the little boy jeffy 🙂

  2. […] Link […]

  3. […] Direct Link […]

  4. I am having trouble getting the Geolocation update function to fire more than once. Any ideas? Could it be that I am on a Motorola Droid and not a Nexus One?

    Thank you – I look forward to seeing your app!

  5. Hi,
    Mark Doherty is coming this Aug at Adobe Flash Platform Summit 2010 to Speaks on AIR 2.5 for Android. The summit will take place on 25 and 26 Aug’10. For details log on to adobesummit.com

  6. Have you finished this app? Im curious to how the data is sent. I use ColdFusion as well

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: