Using the GPS
Most smartphones have a GPS chip. This will enable you to create location-aware applications. In this recipe, we'll take a look at how we can obtain the location of a device, and show it on the screen.
Getting ready
I've used the font Junction in this example, an open source font made by The League of Moveable Type. You can download the font from http://www.theleagueofmoveabletype.com/junction. Drag it onto the Processing editor so you can use it in your sketch.
How to do it...
We'll start by importing some of the core android packages, and declare some variables we need to make it work:
import android.content.Context; import android.location.*; import android.os.Bundle; LocationManager manager; GPSLocationListener gps; float latitude; float longitude; float accuracy; String provider; PFont junction;
The next thing you need to do is to create a new tab, and name it GPSLocationListener.pde
. We'll write a class in this tab that implements the LocationListener
interface.
class GPSLocationListener...