Build your own Android App Dev Empire

Get Instant Access

Location-Based Services (LBS) enable some of the most popular mobile applications. Location can be integrated with many functions, such as Internet searching, picture taking, gaming, and social networking. Developers can leverage the available location technology to make their applications more relevant and local.

This chapter introduces methods to obtain the device's location and then track, geocode, and map it. In addition, there are recipes on overlaying the map with markers and views.

An application requires the following to access the location services from the Android system:

■ LocationManager—Class providing access to Android system location services

■ LocationListener—Interface for receiving notifications from the LocationManager when the location has changed

■ Location—Class representing a geographic location determined at a particular time

The LocationManager needs to be initialized with the Android system service called LOCATION_SERVICE.This provides the application with the device's current location, movement and can also alert when the device enters or leaves a defined area. An example of initialization is

LocationManager mLocationManager; mLocationManager = (LocationManager)

After the LocationManager instance is initiated, a location provider needs to be selected. Different location technologies might be available on the device (such as Assisted Global Positioning System (AGPS),Wi-Fi, and so on), and a general way to find a proper location provider is to define the accuracy and power requirement. This can be done using the Criteria class defined in android.location.Criteria.This enables the Android

Was this article helpful?

0 0
Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook

Post a comment