This tutorial will show how to use the Android's location sensor.
There is a nice concise discussion of how to use App Inventor's sensor's in Chapter 23 of Prof. Wolber's textbook.
Prof. Wolber has also written a nice tutorial on this subject. We will be customizing that tutorial.
A GPS reading consists of three data: latitude, longitude, and altitude. Your latitude is your distance in degrees north or south of the equator, with north positive and south negative. The range is -90 to +90.
Your longitude is your distance east or west of the Prime Meridian, which goes through Greenwich England. East coordinates have positive values and west coordinates are negative. The values range from -180 to +180. Values on the Meridian are 0.
http://maps.google.com/?ie=UTF8&ll=41.744416,-72.691043&spn=0.001053,0.002631&t=h&z=19Those coordates, (41.744416,-72.691043), are on the Trinity College campus.
Let's set up the following interface in the App Inventor Designer that includes
a LocationSensor. It contains several labels, a button, and LocationSensor:
Using the LocationSensor in your app is primarily a matter of
responding to location change events using the LocationChanged
event handler. In this first example, whenever the sensor detects a
change in location, the event handler simply display's the phone's
latitude and longitude and speaks its current address.
Of course, in order to test this app, you will have to download it to your phone and then walk around outdoors.
For this homework assignment you will download and play with a version
of the location demo. Use the following QR code to download the app
to your phone.
Use Google maps to choose a rectangular section of the Trinity campus and then use the app to find the GPS coordinates of the four corners of the rectangular region -- i.e., top-left, top-right, bottom-left, and bottom-right. Next class we'll use the coordinates to improve the app to show our location on the Trinity map.
Here's the app's sourcecode. Download it and play with it before the next class.