Android 网络\u提供程序未返回或正在工作

Android 网络\u提供程序未返回或正在工作,android,networking,location,location-provider,Android,Networking,Location,Location Provider,我想找到设备的当前位置,无论它在哪里。下面的代码在室外运行良好,但在室内不会通知更新 下面的代码无法访问网络提供程序,只返回GPS提供程序和被动提供程序,为什么?同一设备中的其他应用程序可以在室内找到我的位置 if ( mLocationManager==null ) mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); Location l; for ( String provider : m

我想找到设备的当前位置,无论它在哪里。下面的代码在室外运行良好,但在室内不会通知更新

下面的代码无法访问网络提供程序,只返回GPS提供程序和被动提供程序,为什么?同一设备中的其他应用程序可以在室内找到我的位置

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;
}
当我将其更改为硬编码网络\u提供程序时:

    if ( mLocationManager==null )
    mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

Location l;
List<String> providers = new ArrayList<String>();
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;
}

在设置中启用了WLAN辅助定位,但mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)返回false。而同一设备中的其他应用程序可以正确定位。我不认为这是对其他问题的重复,目前没有答案,该设备是摩托罗拉XT928,无法帮助重新启动。或者切换到Google Play服务会有所帮助,因为该地区的许多设备Google Play都被禁用。可能与相同的问题,没有明确的答案。你有互联网连接吗?您需要访问Internet才能获得基于网络的位置是的,当然可以。一些开发者在安卓4.0+上找到了它,但没有给出明确的答案。在没有操作系统更新的情况下,同一台设备上的其他一些应用程序可以正确定位,因此我认为有一种编程方法可以做到这一点。
11-17 14:06:13.145: E/AndroidRuntime(7896): Caused by: java.lang.IllegalArgumentException: provider=network