获取"提供程序未启用 |提供商错误{提供商='网络'}' 在呼叫'tracker.startListening();'即使启用了 WiFi



我正在使用此库,并尝试检索这样的当前位置坐标:

settings =
                new TrackerSettings()
                        .setUseGPS(false)
                        .setUseNetwork(true)
                        .setUsePassive(true)
                        .setTimeBetweenUpdates(30 * 60 * 1000);
        tracker = new LocationTracker(getBaseContext(), settings) {
            @Override
            public void onLocationFound(Location location) {
                // Do some stuff
                currentLatDouble = location.getLatitude();
                currentLngDouble = location.getLongitude();
            }
            @Override
            public void onTimeout() {
            }
        };
        tracker.startListening();

但是,我遇到了这个错误:

W/LocationTracker: Provider (network)
                   fr.quentinklein.slt.ProviderError: Provider is not enabled | ProviderError{provider='network'}

WiFi不是网络提供商,还是我需要编写一些与LocationManager相关的代码?

请让我知道这里有什么问题。

在清单文件中添加了以下权限

<uses-permission android:name="android.permission.INTERNET" />
Allows applications to open network sockets.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Allows an app to access approximate location.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Allows an app to access precise location.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Allows applications to access information about networks.
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Allows applications to access information about Wi-Fi networks.

另外

<uses-feature
    android:name="android.hardware.location.network"
    android:required="false" />
<uses-feature
    android:name="android.hardware.location.gps"
    android:required="false" />

最新更新