I am just trying to develope a little app, that gives me my current position. So I found this plugin that I entered to my code. Now, that I got everything to compile - the app starts but then, without warning ends. No crash, no nothing. Even Xamarin doesnt show any sign of crash. Can you guys help me out? I have tried nothing, and Im all out of ideas... ;)
thanks again!
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
//Initialize buttons:
Button StartButton = FindViewById<Button>(Resource.Id.startbutton);
TextView txtTestGps = FindViewById<TextView>(Resource.Id.GpsTest);
ShowGpsCoordinates(StartButton, txtTestGps);
}
private void ShowGpsCoordinates(Button StartButton, TextView txtTestGps)
{
Task<double> xy = GiveGpsLocation();
double xyOut = xy.Result;
StartButton.Click += (sender, e) =>
{
txtTestGps.Text = xyOut.ToString();
};
}
private async Task<double> GiveGpsLocation()
{
double DoubleWithCoordinates = 0.0;
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync(10000);
// Console.WriteLine("Position Status: {0}", position.Timestamp);
// Console.WriteLine("Position Latitude: {0}", position.Latitude);
// Console.WriteLine("Position Longitude: {0}", position.Longitude);
DoubleWithCoordinates = position.Latitude;
return DoubleWithCoordinates;
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…