January 2012
Intermediate to advanced
282 pages
7h 4m
English
Any real estate agent will tell you the three most important things are location, location, location. Android understands that and lets your application know where the device is. (It won't tell you if the device is in a good school district, although I am pretty sure there is an application for that.) Listing 7–8 shows how to request location updates using the system location services.
Listing 7–8. Receiving Location Updates
private void requestLocationUpdates() {
LocationManager lm = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
List<String> providers = lm.getAllProviders();
if (providers != null&& ! providers.isEmpty()) { LocationListener listener = new LocationListener() { ...Read now
Unlock full access