Wenn ich die CLLocationManager-Instanz nur auf UIThread erstelle, wird das LocationUpdated-Ereignis ausgelöst. Warum passiert das? Es gibt keine Hinweise in der Dokumentation von Xamarin und Apple, dass CLLocationManager created
auf UIThread sein muss.Warum liefert CLLocationManager keine zu bearbeitenden Ereignisse?
Einige Code fragt locationManager.RequestWhenInUseAuthorization(); NSLocationWhenInUseUsageDescription wird gefassten in Info.plist
private void CreateLocationManagerWorkingOption() {
ExecuteOnMainThread (() => {
locationManager = new CLLocationManager();
});
locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
OnLocationChanged (locationManager,e.Locations [e.Locations.Length - 1]);
};
}
private void CreateLocationManagerNotWorkingOption() {
ExecuteOnSomeThread(()=> {
locationManager = new CLLocationManager();
});
locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
OnLocationChanged (locationManager,e.Locations [e.Locations.Length - 1]);
};
}
private void StartTrackingImpl() {
ExecuteOnMainThread (() => locationManager?.StartUpdatingLocation());
}
Sie wirkt sich nur auf StartUpdatingLocation und andere Aktualisierungsmethoden aus. Es gibt keine Informationen zum Konstruktor. Außerdem habe ich Xamarin-Dokumentation gemeint, weil mono den CLLoationManager beeinflussen kann. – Alexander