Location Services

Android gives your applications access to the location services supported by the device through the classes in the android.location package. The central component of the location framework is the LocationManager system service, which provides an API to determine location and bearing if the underlying device (if it supports location capabilities).

As with other system services, you do not instantiate a LocationManager directly. Rather, you request an LocationManager instance from the system by calling getSystemService(Context.LOCATION SERVICE). The method returns a handle to a new LocationManager instance.

Once your application has a handle to a LocationManager instance, your application will be able to do three things:

• Query for the list of all LocationProviders known to the LocationManager for its last known location.

• Register/unregister for periodic updates of current location from a LocationProvider (specified either by Criteria or name).

• Register/unregister for a given Intent to be fired if the device comes within a given proximity (specified by radius in meters) of a given lat/long.

However, during initial development in the emulator, you may not have access to real data from a real location provider (Network or GPS). In that case, it may be necessary to spoof some data for your application using a mock location provider.

Note: If you've used mock LocationProviders in previous versions of the SDK, you can no longer provide canned LocationProviders in the /system/etc/location directory. These directories will be wiped during boot-up. Please follow the new procedures outlined below.

0 0

Post a comment