B
ben56a
Ambitioniertes Mitglied
- 0
Hallo,
Location Listener:
Das Problem ist, dass die Methoden GetLat und GetLon immer 0.0 zurückgeben!
ich habe alles mögliche versucht, leider ohne Erfolg. Hat jemand eine Idee, woran es liegen könnte?
Code:
public GPSManager(Context cntx)
{
context = cntx;
/* Use the LocationManager class to obtain GPS locations */
String provider = LocationManager.GPS_PROVIDER;
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
MyLocationListener loc = new MyLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, loc);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, loc);
}
public double GetLat()
{
return latitude;
}
public double GetLon()
{
return longitude;
}
Location Listener:
Code:
public class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(android.location.Location loc)
{
latitude = loc.getLatitude();
longitude = loc.getLongitude();
Toast msg = Toast.makeText(context, latitude+":"+longitude, Toast.LENGTH_LONG);
msg.show();
}
@Override
public void onProviderDisabled(String provider)
{
}
@Override
public void onProviderEnabled(String provider)
{
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
}
Das Problem ist, dass die Methoden GetLat und GetLon immer 0.0 zurückgeben!
ich habe alles mögliche versucht, leider ohne Erfolg. Hat jemand eine Idee, woran es liegen könnte?