========================================
GPS: Global Positioning System
GPS consists of three parts: the space part of the GPS satellite, the control station composed of several ground, and the receiver in the user's hands.
Android provides telephonymanager for phone management support
Provides audiomanager for audio management
Locationmanager is provided to support GPS.
Get : Locationmanager lm = (Locationmanager) Context. Getsystemservice (Context.location_service);
Similar to the method of obtaining Telephonymanager,audiomanager.
list<string> providers = Lm.getallproviers ();//Gets the system all available Locationprovider objects, returns list<string>
The names collection of providers.
Locationprovider:
Gets the Locationprovider object:
* The specified Locationprovider object is obtained by name. Locationprovider Provider = Lm.getprovider (Locationmanager.gps_provider);
* * Obtain Locationprovider,criteria by criteria equivalent to a filter, Location.getbestprovider (criteria Criteria,boolean enabledonly); To
Gets the provider that meet the criteria.
The most commonly used locationmanager.gps_provider in Locationprovider
Location
Through the program can be real-time access to the user's latitude, dimension, height, direction, movement speed and so on. For details see: Crazy Android Handout P667
Step:
1. Gets the Locationmanager object for the system. Note View: Locationmanager API documentation.
locationmanager lm = (locationmanager) Context. Getsystemservice (Context.location_service);
2. Use Locationmanager to obtain positioning information by specifying Locationprovider, which is represented by the location object
locationprovider Provider = Lm.getprovider (String name);
3. Gets the positioning information from the Location object.
//Location location = lm.getlastknownlocation (String provider);
//access to GPS requires permission: it should be configured in Andoridmanifest.xml:
<uses-permission android:name= " Android.permission.ACCESS_FINE_LOCATION "/>
Imminent warning;
Locationmanager provides a method: Addproximityalert (double latitude,double longitude,float radius,long expriration, Pendingintent intent); Add a proximity warning.
The corresponding parameters are: Longitude, dimension, duration of the warning: when 1 lasts forever, intent means: The intent component that is triggered when it is near.
==============================================================================
Summary:
This chapter mainly introduces the GPS support provided by Android, the majority of mobile phones have provided the GPS hardware support, can be used as the GPS positioning System receiver, and we have to do is to obtain GPS positioning information from the Android system.
Need to focus on: Locationmanager,loccationprovider and Locationlistener and other API functions and usage, and through their monitoring to obtain GPS location information.
Acquiring GPS is just one of the basic prerequisites for developing other applications, and then we'll use Google Maps to locate, track, etc.
Baidu map is very good map, the United States Group Positioning System is: Soso map. SouFun is also the map of Soso
Android's GPS learning notes