Location

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() { ...

Get Pro Android Apps Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.