Hi all
I have added Xamarin.Mobile to my Xamarin.Forms-project and want now to implement Geolocator for all platforms.
It seems to work with iOS and also with WP, but I have a (hopefully last) problem with Android.
Code:
var b4 = new Button { Text = "Aktuelle Positionausgeben" };
b4.Clicked += async (sender, e) =>
{
#if Android
locator = new Geolocator(this) { DesiredAccuracy = 50 };
#else
locator = new Geolocator { DesiredAccuracy = 50 };
#endif
//
Xamarin.Geolocation.Position position = await locator.GetPositionAsync(timeout: 10000); // Achtung! Da Xamarin.Maps ebefalls im Projekt eingebunden ist, ergeben sich ZWEI Definitionen von Position
string cPosition = "Lat: " + position.Latitude.ToString() + ", Long: " + position.Longitude.ToString() + " TimeStamp: " + position.Timestamp.ToString();
await DisplayAlert("Aktuelle Position", cPosition, "OK");
};
The problem is, that I have an error-message (only) for Android to:
locator = new Geolocator(this) { DesiredAccuracy = 50 };
In the example, there is described, that - for Android - the page has to add as parameter.
Error-Messages (translated to English):
The best accordance for the overloaded 'Xamarin.Geolocation.Geolocator.Geolocator(Android.Content.Context)'-Method has a few invalid arguments.
Convert from 'MatrixGuide.MG_TestPageAllgemein' (note: this is the page-name) in 'Android.Content.Context' not possible.
So It don't run without a parameter (how in run's in iOS and WP), but it also don't run with the page (this) as parameter,
What do I have to pass as parameter for Android...?
Thanks a lot for any help (It seems as only a small peace is missing)...