1

私のアプリには、位置精度をログアウトして地図上にマーカーを配置する位置リスナーがありますが、精度は常に 900 マーク前後であり、私の位置は実際の位置から 0.2 ~ 0.5 マイル離れています。Google マップを読み込むと、数メートル以内に現在地が表示されます。

正確な位置を確保するためにどのような方法がありますか? マニフェストにこれらの権限があります

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

そして、これが私のリスナーです

LocationListener searchUsingLocation = new LocationListener() {
                @Override
                public void onLocationChanged(Location location) {
                    float accuracy = location.getAccuracy();
                    Log.d("FUApp", "Location changed: "+accuracy);
                    List<JSONObject> centres = sortVenuesByNearest(location);
                    try {
                        populateList(centres);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    setRefreshActionButtonState(false, R.id.search_using_location);

                }

                @Override
                public void onStatusChanged(String s, int i, Bundle bundle) {

                }

                @Override
                public void onProviderEnabled(String s) {

                }

                @Override
                public void onProviderDisabled(String s) {

                }
            };
            Log.d("FUApp", "Starting request");
            locationService.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 50, 5, searchUsingLocation);

編集: また、電話の設定、位置情報へのアクセス、GPS サテライト、Wi-Fi とモバイル ネットワークの場所もオンになっています。

4

3 に答える 3

11

Android tries to mask the reality of the hardware from us, but in practice there are only two location providers: GPS and network. GPS location is slow and not all devices have it, but it is accurate. Network location is faster and is supported by almost all devices, but it is less accurate.

If you know which provider you want, you are better off specifying it explicitly. It your app can work with either provider, you may want to ask the user to choose which he wants to use. Do not rely on what Android tells you, because most cheap devices are horribly provisioned, and may lie to you.

于 2013-09-18T10:24:39.810 に答える
4

あなたは聞いているだけLocationManager.NETWORK_PROVIDERです。より精度が必要な場合は、他のプロバイダーをリッスンする必要がありますが、少しお待ちください:)

Google は、融合されたロケーション プロバイダーを使用して、地図とロケーションの管理を改善しました。https://developer.android.com/google/play-services/location.html

融合した場所で。最適なロケーション プロバイダーを照会する必要はありません。高い精度を得たい場合は、ロケーション リクエストのみに設定します。

setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) 
于 2013-09-18T10:35:36.760 に答える