我试图得到latitude
andlongitude
但有时network is available
我没有得到latitude
and的价值longitude
。我正在使用MyLocationListener类并设置条件,但有一段时间value
没有得到。
protected void showCurrentLocation()
{
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null)
{
counter++;
latitude=location.getLatitude();
longitude=location.getLongitude();
altitude=location.getAltitude();
}
}
private class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location location)
{
counter++;
latitude=location.getLatitude();
longitude=location.getLongitude();
altitude=location.getAltitude();
}
@Override
public void onStatusChanged(String s, int i, Bundle b)
{
}
@Override
public void onProviderDisabled(String s)
{
}
@Override
public void onProviderEnabled(String s)
{
}
}