Thursday, February 24, 2011

Android App Inventor - Simple SMS

Recently, I have been doing some further development on Android App Inventor. My focus for this work was getting the application to send and receive SMS messages. To aid others in doing this I put together this tutorial which shows this.

The first part of the tutorial shows how to send an SMS from within an App Inventor App. This is relatively simple and requires a a couple of text boxes (Mobile Number & Message Text) and a button to press to send the message.

You will also need to add a non-visual Texting component to the form. 



Once the form has been created, the Blocks required to send a message should be configured as in the following image.


This block of code is executed when the user clicks the Send Message button. The first two actions are to set the Mobile Number and Message text on the Texting object to the values in the text boxes.

The last action calls the Texting.SendMessage method to actually send an SMS. Simple.

Note: This code does not do any error checking or validation. Erroneous data may cause the application to Force Close.

The second part of the tutorial will show how to make an App Inventor application respond to an SMS that it receives. For this application there is no GUI as the application handles the logic in the background. All we need are some blocks to intercept the SMS messages received.



This block of code is executed when the phone gets a SMS message.

The MessageRecieved method exposes two values: number and messageText. You can store these in a couple of variables.


The second thing this block does is to check the message to see if it contains the text 'Status?' If this text is in the message it will create a new TextMessage using the received number and respond with the message 'All Good!'. This is a simple application for this but could be used for such things as responding with a user location or responding with a simple message if the user is unavailable.

I hope this tutorial has been helpful. Please feel free to comment if you need further information.

I have added a link to the source code here.

My other App Inventor tutorials:
App Inventor - Location Services
App Inventor - Lists

Sunday, February 20, 2011

GPS Visualiser

One of the online tools I use regularly while working with GPX files and mapping is the GPS Visualizer website. The GPS Visualizer website is a collection of tools that work with GPX files to produce maps and profiles of GPS tracks.

The main functions I use on the website are:

1. Draw a Map

The Draw a Map page allows you to select a GPX file and display it overlayed on a variety of different map types including Google Streetmap, Google Satellite and Google Terrain. Once created the image can be captured as an image file.

2. Draw a Profile

The Draw a Profile page allows you to select a GPX file and display a elevation profile for this GPX file. The profile can be colorcoded to show elevation, speed, heart rate and other data points. Where a GPX file does not include elevation data the form gives the ability to add elevation data from a DEM dataset.

3. Lookup Elevations

The Lookup Elevation page allows you to recreate the elevation data for a GPX track using a DEM dataset. This is useful if the existing GPX file does not have elevation data or the data is incomplete. Rather than directly rendering a profile (as in point 2) the page gives you the option to save a new GPX file.

As well as these easy to use functions there are a multitude of ways to make use of the GPS Visualizer service. If you are using GPX files on a regular basis this service is a very handy addition to your tools.