Location

J

Janakar

Neues Mitglied
0
Ich bin totaler Anfänger und plage mich mit der Ausgabe der Längen- und Breitengrade.
Das Handy bricht leider ab und gibt eine Fehlermeldung heraus.
Kann mir jemand helfen. Das Internet ist voll mit nicht funktionierenden Codes zu diesem Fall.
Ich brauche einen der LÄUFT!!!! Hilfe!!!

package de.photochallenge.HelloGPSLocation;
import android.app.Activity;
import android.content.Context;
import android.hardware.SensorManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.*;

public class HelloGPSLocation extends Activity {
volatile Location curLocation = null;
private LocationManager mLocationManager;

@Override
public void onCreate(Bundle savedInstanceState) {
mLocationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
curLocation = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,2000,10,gpsListener);
updateWithNewLocation(curLocation);

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}

private void updateWithNewLocation(Location mLocation) {
String mText;

TextView myLocationText;
myLocationText = (TextView)findViewById(R.id.myLocationText);

if(mLocation != null){
double lat = mLocation.getLatitude();
double lng = mLocation.getLongitude();

mText = "Latitude:" + lat + "\nLongitude:" + lng;
}
else {
mText = "No location found";
}
myLocationText.setText(mText);
}


private final LocationListener gpsListener = new LocationListener(){

public void onLocationChanged(Location xLocation)
{ updateWithNewLocation(xLocation);
}
public void onProviderDisabled(String provider){
updateWithNewLocation(null);
}
public void onProviderEnabled(String provider){}
public void onStatusChanged(String provider, int status, Bundle extras){}
};



}
 
Dein Fehler habe ich gefunden ;)

public void onLocationChanged(Location xLocation)
{ updateWithNewLocation(xLocation);
}
public void onProviderDisabled(String provider){
updateWithNewLocation(null);
}
public void onProviderEnabled(String provider){}
public void onStatusChanged(String provider, int status, Bundle extras){}
};

Schreibe es ohne
updateWithNewLocation(xLocation);
updateWithNewLocation(null);
 

Ähnliche Themen

W
  • WuDiDong
Antworten
3
Aufrufe
765
jogimuc
J
R
  • RealNiclas
Antworten
5
Aufrufe
1.389
RealNiclas
R
B
  • Braesident
Antworten
12
Aufrufe
1.674
markus.tullius
markus.tullius
Zurück
Oben Unten