Android's GPS learning notes

Source: Internet
Author: User

========================================
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.