J'essaie d'obtenir les données de champ magnétique pour une application de plaque croisée développée par xamarin. Je suis assez débutant en développement mobile notamment Xamarin. J'ai donc le code mot Bonjour:Comment puis-je obtenir des valeurs de magnétomètre avec xamarin en utilisant Device Motion Plugin?
public App()
{
// The root page of your application
MainPage = new ContentPage {
Content = new StackLayout {
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Welcome to Xamarin Forms!"
}
}
}
};
}
Et je veux afficher 3 valeurs de coordonnées du magnétomètre dans la première page. Device Motion Plugin est un plugin multiplateforme, j'ai aussi ce code mais je ne sais pas comment faire pour afficher ces valeurs dans l'application.
CrossDeviceMotion.Current.Start(MotionSensorType.Magnetometer);
CrossDeviceMotion.Current.SensorValueChanged += (s, a) =>
{
switch (a.SensorType)
{
case MotionSensorType.Magnetometer:
Debug.WriteLine("A: {0},{1},{2}", ((MotionVector)a.Value).X, ((MotionVector)a.Value).Y, ((MotionVector)a.Value).Z);
break;
}
};