Note that there are some explanatory texts on larger screens.

plurals
  1. PONETWORK_PROVIDER not returned or working
    primarykey
    data
    text
    <p>I want to locate the current place of the device wherever it is. The code below works fine outdoors, but no updates are notified indoors.</p> <p>The code below can't access NETWORK_PROVIDER, only GPS_PROVIDER and PASSIVE_PROVIDER are returned, why? Other apps in the same device can locate my position indoors.</p> <pre><code>if ( mLocationManager==null ) mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); Location l; for ( String provider : mLocationManager.getAllProviders() ){ mLocationManager.requestLocationUpdates(provider, 1000, 1, locationListener); l = mLocationManager.getLastKnownLocation(provider); if ( isBetterLocation(l, currentBestLocation) ) currentBestLocation = l; } </code></pre> <p>when I change it to hard-coded NETWORK_PROVIDER:</p> <pre><code> if ( mLocationManager==null ) mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); Location l; List&lt;String&gt; providers = new ArrayList&lt;String&gt;(); providers.add(LocationManager.GPS_PROVIDER); providers.add(LocationManager.NETWORK_PROVIDER); // for ( String provider : mLocationManager.getAllProviders() ){ for ( String provider : providers ){ mLocationManager.requestLocationUpdates(provider, 1000, 1, locationListener); l = mLocationManager.getLastKnownLocation(provider); if ( isBetterLocation(l, currentBestLocation) ) currentBestLocation = l; } </code></pre> <p>the following exception is thrown:</p> <pre><code>11-17 14:06:13.145: E/AndroidRuntime(7896): Caused by: java.lang.IllegalArgumentException: provider=network </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload