Cannot convert string to Location
Bonjour,
J'ai un problème pour un cast lorsque je récupère un Intent.
Peut être je ne fais pas ça de la bonne manière..
Pouvez vous m'aider?
Je vous remercie d'avance.
Cordialement
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
public class MapBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context aContext, Intent aIntent){
Log.i("MapBroadcastReceiver:onReceive()", "** message received ");
// extract broadcasted intent parameters: weather data & location
CurrentWeatherData weatherData = (CurrentWeatherData) aIntent.getExtras().getString(WeatherMapActivity.INTENT_PARAM_CURRENT_WEATHER);
Location newLocation = (Location) aIntent.getExtras().getString(WeatherMapActivity.INTENT_PARAM_LOCATION);
// convert Location to a GeoPoint
GeoPoint geoPoint = Tools.convertLocationToGeopoint(newLocation);
// update the map center with the new location
// mMapController.animateTo(); or
mMapController.setCenter(geoPoint);
// update the overlay with the new location
mWeatherOverlay.updateOverlayData(geoPoint, weatherData);
} |
Ce sont ces deux lignes qui ne fonctionne pas :
Code:
1 2 3
|
CurrentWeatherData weatherData = (CurrentWeatherData) aIntent.getExtras().getString(WeatherMapActivity.INTENT_PARAM_CURRENT_WEATHER);
Location newLocation = (Location) aIntent.getExtras().getString(WeatherMapActivity.INTENT_PARAM_LOCATION); |