0

我有一个我使用的应用程序isProviderEnabled(LocationManager.NETWORK_PROVIDER 但是当我将此应用程序放入 Samsung Galaxy Young 时,即使在“设置”中启用了false该选项,它也会始终返回。Packet Data

为什么会出错?

这是我的代码的一部分:

boolean isNetworkEnabled = false;

    locationManager = (LocationManager) c
            .getSystemService(this.c.LOCATION_SERVICE);

    // getting network status
    isNetworkEnabled = locationManager
            .isProviderEnabled(LocationManager.NETWORK_PROVIDER);

Toast.makeText(c.getApplicationContext(), "Obteniendo network provider = "+isNetworkEnabled, Toast.LENGTH_SHORT).show();

    if (isNetworkEnabled) { 
        Log.i(LOGTAG, "obtiene localizaciones de network provider NET.... ");
        ret = 0;
        LocationManager lm = (LocationManager) c
                .getSystemService(c.LOCATION_SERVICE);
        myloc = null;
        myloc = new mylocationlistener();
        LocationListener locationListener = myloc;
        Log.i(LOGTAG, "myloc.... latitude=" + myloc.getLatitude()
                + " Longitude=" + myloc.getLongitud());
        Toast.makeText(c.getApplicationContext(), "conectandose AGPS...lat = "+myloc.getLatitude()+ " Longitud = "+myloc.getLongitud(), Toast.LENGTH_SHORT).show();
        lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                locationListener);                  
    } else {

        ret = -1;
    }
4

1 回答 1

0

您确定启用定位服务了吗?您可以通过设置应用程序(在我的 S3 上的个人下)进行配置。

于 2013-02-09T21:20:32.580 回答