0
私はxamarinによって開発されたクロスプレート・アプリケーションの磁場データを取得しようとします。私はモバイル開発、特にXamarinでかなり初心者です。 だから私は、こんにちはWordのコードがあります。Device Motion Pluginを使用して、xamarinで磁力計の値を取得するにはどうすればよいですか?
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!"
}
}
}
};
}
をそして私は、最初のページでmagnetometreの3つの座標値を表示したいです。
Device Motion Pluginはマルチフォームプラグインですが、このコードもありますが、これらの値をアプリケーションに表示する方法はわかりません。
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;
}
};