How to improve GPS location Accuracy in Android

做~自己de王妃 提交于 2019-12-17 22:54:15

问题


Hi im working on an app that uses GPS location. My testing devices are Nexus One and Htc Mytouch 3g Slide.

So does anyone know how to improve the GPS location accuracy?


回答1:


see this post: Google Maps & apps with mapview have different current positions

Are you talking about your own MapView witin your app or the Google Maps app? In your own map, use both network provider and gps provider to get the location. Gps only works outdoors under free sky and is more accurate, while a network provider works indoors as well but less accurate.

Also read this: http://forum.sdx-developers.com/android-2-1-development/cdma-lockup-wifi-use-wireless-networks-and-gps!/msg22834/#msg22834




回答2:


Since API 9 you can use some constants for the setAccuracy method

lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_HIGH);  
lm.getBestProvider(criteria, true);

ACCURACY_HIGH less than 100 meters
ACCURACY_MEDIUM between 100 - 500 meters
ACCURACY_LOW greater than 500 meters

here are the details




回答3:


While it's true that since API 9 there are some new possibilities in terms of accuracy settings, what @dev mz said won't work. You can't use the new constants directly in criteria.setAccuracy. Instead you can use these new features like this:

        //All your normal criteria setup
        Criteria criteria = new Criteria();
        //Use FINE or COARSE (or NO_REQUIREMENT) here
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setPowerRequirement(Criteria.POWER_LOW);
        criteria.setAltitudeRequired(true);
        criteria.setSpeedRequired(true);
        criteria.setCostAllowed(true);
        criteria.setBearingRequired(true);

        //API level 9 and up
        criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
        criteria.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
        criteria.setBearingAccuracy(Criteria.ACCURACY_LOW);
        criteria.setSpeedAccuracy(Criteria.ACCURACY_HIGH);

As for your question, be aware that we are talking about Criteria for the incoming location updates. This won't actually improve the quality of the GPS data because that's device/hardware/network specific. It just acts like a filter for the incoming geolocations.



来源:https://stackoverflow.com/questions/3412416/how-to-improve-gps-location-accuracy-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!