Android:LocationManager WiFi位置

时间:2015-12-18 21:04:53

标签: android gps locationmanager

我使用此代码,但我只在GPS开启时获取位置...你能告诉我为什么吗?我想特别使用WiFi。

        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    public void requestPermissions(@NonNull String[] permissions, int requestCode)
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for Activity#requestPermissions for more details.
        return;
    }

    //Sorgt für die Updates

    locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 60 * 1000, 0, this);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60 * 1000, 0, this);
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60 * 1000, 0, this);
}

@Override
public void onLocationChanged(Location location) {
    //Werte hochladen, MYSQL
    new DatabaseConnector(false).execute()
}

0 个答案:

没有答案