How mobile phones are positioned

Source: Internet
Author: User

GPS: triangle positioning, positioning accuracy, the minimum accuracy of about 15 meters, shortcomings--positioning speed slow, boot time long base station: the use of triangular positioning method, positioning fast, low positioning accuracy of 30 meters to 2 km network: using IP to locate; AGAP: Network Assistant location System ; now locate on the phone in this way; Add permissions to the manifest file:
  
 
  1. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 注:最佳定位方式通过GPS、
  2. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>注:网络定位
  3. <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>注:车载系统定位
Permissions annotations: Allows an app to access precise location from location sources such as GPS, cell towers, and Wi-Fi. (Android.permission.ACCESS_FINE_LOCATION)allows an app to access approximate location derived from network location sources such as cell towers and Wi-Fi (Android.permission.ACCESS_COARSE_LOCATION)allows an application-to-create mock location providers for testing (Android.permission.ACCESS_MOCK_LOCATION)
Locating api:1 and getting Locationmanager objects through system services
 
   
  
  1. LocationManager lm=(LocationManager)getSysyrmService
2. By callingRequestlocationupdates (Stringprovider, long mintime, float mindistance,Locationlistenerlistener) to achieve positioning
 
   
  
  1. lm.requestLocationUpdates("gps",0,0,new MyLocationLiseter());
Parameter comment:    provider: Get location information: gps\ base station \ Network    mintime: At least how long it takes to get information back    mindistance: At least move multiple long distances to regain information    Listener: Listener for position changeCustomizing the Locationlistener and serializing specific positioning information to a local
  
 
  1. private class MyLocationLiseter implements LocationListener{
  2. /**
  3. * 位置发生变化调用这个方法
  4. */
  5. @Override
  6. public void onLocationChanged(Location location) {
  7. //维度
  8. double w = location.getLatitude();
  9. //经度
  10. double j = location.getLongitude();
  11. // 精确度
  12. double a = location.getAccuracy();
  13. String l = w+","+j+ "," +a;
  14. System.out.println("=================="+l);
  15. SharedPreferences sp = getSharedPreferences("config", Context.MODE_PRIVATE);
  16. Editor editor = sp.edit();
  17. editor.putString("location", l);
  18. editor.commit();
  19. }
  20. /**
  21. * 某一种定位方式的状态发生变化调用这个方法
  22. * 打开--关闭
  23. * 关闭--打开
  24. */
  25. @Override
  26. public void onStatusChanged(String provider, int status, Bundle extras) {
  27. }
  28. /**
  29. * 某一种定位方式的可用时发生变化时调用这个方法
  30. * 不可用--可用
  31. */
  32. @Override
  33. public void onProviderEnabled(String provider) {
  34. // TODO Auto-generated method stub
  35. }
  36. /**
  37. * 某一种定位方式的不可用时发生变化时调用这个方法
  38. * 可用--不可用
  39. */
  40. @Override
  41. public void onProviderDisabled(String provider) {
  42. // TODO Auto-generated method stub
  43. }
  44. }





From for notes (Wiz)

How mobile phones are positioned

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.