Android Scripting: Location-based Text Message Delivery

I’ve hacked together a small Perl script that sends a text message when your location matches a pre-selected position on the globe. Using the API provided by the Android Scripting Environment, the script will automatically send a custom text message to one of your contacts as soon as you reach a specific destination. The script has been developed with hands free in mind, and will speak to you using TTS when it’s sent a message to your chosen contact, rather than displaying a dialog. It’s also designed to be ran as a background process. The script will sleep between checking your GPS position, so it shouldn’t be too battery-hungry.

The flow of the application is quite straight forward:

  1. Pick a contact
  2. Write them a text message
  3. Select a destination
  4. Reach your destination; the script will automatically send an SMS and tell you it’s done so using TTS

I’ve added a few niceties to the text message system, allowing for tags to be inserted into the message that are substituted for actual GPS information just before the message is sent. These tags include:

  • admin_area
  • country_code
  • country_name
  • feature_name
  • locality
  • postal_code
  • thoroughfare
  • sub_admin_area
  • map_link

Tags must be encapsulated between ‘%‘ (percentage) signs. For example, to send your current position as a Google Maps link, the following text message could be entered:

Hi! Just thought I’d let you know that I’m just entering %admin_area% now, and should be with you shortly. Here’s my Google Maps position: %map_link%

When you reach your chosen destination (let’s assume central Cheshire on your way to Manchester), the above message will be interpreted, and the tags %admin_area% and %map_link% will be substituted, and the following message sent to your contact:

Hi! Just thought I’d let you know that I’m just entering Cheshire now, and should be with you shortly. Here’s my Google Maps position: http://maps.google.com/maps?q=53.3212348,-2.2966268

You can get yourself a copy from github here. Comments, suggestions, and patches are all welcome. Happy hacking!

This entry was posted in hacking and tagged , , , , , . Bookmark the permalink.

2 Responses to Android Scripting: Location-based Text Message Delivery

  1. Cameron says:

    Alex,

    Nice piece of work. Do you konw if it is possible to pass values from a perl script on an android phone to another application? Specifically, I’ve been using the Adobe Air prerelase(now full release) to build some nice front ends, but the Air product is very young and doesn’t have access to native apps or the orientation sensor (not sure why). I’m wondering if its possible to make a call to the perl script and return a value.

  2. Alex says:

    Hi, Cameron. Thanks for your kind comment. Sadly, I don’t think it is possible to call the Perl script from Air, unless their API provides some kind of “exec” method that’ll allow you to run external programs or commands. Although, even if it does support “exec”, Android may disallow its use, given that it’s a security risk, and few people are running their phone rooted.

    Sorry I couldn’t be of more help. Do you have a link for these Air interfaces you’ve created? It’d be interesting to see what you’ve done. Also, if you do manage to get it working (invoking Perl from Air) please let me know! :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>