1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
public class Placement implements LocationListener pour récupérer les informations de localisation :
{
private Double latitude = null;
private Double longitude = null;
public Placement (LocationManager locationManager)
{
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
{
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this);
}
else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
{
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this);
}
else
{
locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 10000, 0, this);
}
}
@Override
public void onLocationChanged(Location location) {
latitude = location.getLatitude();
longitude = location.getLongitude();
Log.i("Localisation => ", latitude + " - " + longitude);
}
@Override
public void onProviderDisabled(String provider) {
}
public Double getLatitude()
{
return latitude;
}
public Double getLongitude()
{
return longitude;
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
String newStatus = "";
switch (status) {
case LocationProvider.OUT_OF_SERVICE:
newStatus = "OUT_OF_SERVICE";
break;
case LocationProvider.TEMPORARILY_UNAVAILABLE:
newStatus = "TEMPORARILY_UNAVAILABLE";
break;
case LocationProvider.AVAILABLE:
newStatus = "AVAILABLE";
break;
}
Log.i("Nouveau statut => ", newStatus);
}
} |
Partager