首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在xamarin中使用Device Motion插件获取磁力仪的值?

如何在xamarin中使用Device Motion插件获取磁力仪的值?
EN

Stack Overflow用户
提问于 2016-07-07 16:39:06
回答 0查看 567关注 0票数 0

我尝试为xamarin开发的交叉平台应用程序获取磁场数据。我是一个移动开发的初学者,尤其是Xamarin。所以我有Hello Word代码:

代码语言:javascript
复制
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!"
                        }
                    }
                }

            }; 


        }

我想在第一页显示磁力计的3个坐标值。

设备运动插件是一个多形式的插件,我也有这个代码,但我不知道如何在应用程序中显示这些值。

代码语言:javascript
复制
        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;

            }
        };
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38240982

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档