O'Reilly logo

Pro Android Apps Performance Optimization by Hervé Guihot

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

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

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