I'm using this library and trying to retrieve current location coordinates like this:

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();

but, I'm getting this error:

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

Isn't WiFi a network provider or do I need to write some code related to LocationManager too?

Please let me know what is wrong here.

1

There are 1 answers

4
Nas On

Added the following permission in manifest file

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

Additionally

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