// GET LATITUDE AND LONGITUDE BY INTERNET
LocationManager lManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
boolean netEnabled = lManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (netEnabled) {
lManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
Location location = lManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null)
{
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
我正在尝试只使用互联网获取lat和long。上面的代码只有在我打开位置时才有效。我需要改变什么?