Pouvez-vous me aider .. l'application a commencé à se bloquer lorsque j'ai ajouté le géocodage pour obtenir le nom de la ville en utilisant la latitude et la longitude ..Gps Android - obtenir Latitude et Longitude
double latitude, longitude;
private TextView lala;
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
longitude = location.getLongitude();
latitude = location.getLatitude();
final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
longitude = location.getLongitude();
latitude = location.getLatitude();
}
public void onProviderDisabled(String arg0) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String arg0) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
// TODO Auto-generated method stub
}
};
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, locationListener);
lala = (TextView) findViewById(R.id.textView1);
Geocoder myLocation = new Geocoder(getApplicationContext(), Locale.getDefault());
List<Address> myList = null;
try {
myList = myLocation.getFromLocation(latitude, longitude, 1);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
lala.setText((CharSequence) myList);
stacktrace s'il vous plaît? – matsjoe