O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Get Coordinates from Network Sensor

After you’ve gotten the GPS sensor working, changing or adding a network sensor is very easy. Add the following declaration after the gpsListener declaration:

LocationListener networkListener;

Copy the code that begins with gpsListener = and ends just before the locationManager.requestLocationUpdates line, and paste it back into the method just before the locationManager.requestLocationUpdates line. You should now have two duplicate gpsListeners. Change all the gpsListener variables in the code you just pasted to networkListener and then add another requestUpdates message after the one that is used to request GPS updates.

locationManager.requestLocationUpdates(LocationManager. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required