我想獲得latitude
和longitude
但有時network is available
但我沒有得到latitude
和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)
{
}
}
實際上你想要什麼? – RAAAAM
你在哪裏調用MyLocationListener類? – SKT