在windows加速度事件动摇通用的应用程序无法正常工作 [英] Accelerometer Shaken event in windows universal app doesn't work

查看:148
本文介绍了在windows加速度事件动摇通用的应用程序无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试检测摇一摇我的电话与加速度计对象动摇事件。加速度计的对象不是空,但是当我摇动手机,它永远不会在 _accelerometer_Shaken 事件去了。

I try to detect a shake on my phone with the Shaken event from Accelerometer object. The accelerometer object is not null but when I shake the phone, it never go in the _accelerometer_Shaken event.

    public int shakeCount = 0;
    Accelerometer _accelerometer = Accelerometer.GetDefault();
    public MainPage()
    {
        this.InitializeComponent();

        if (_accelerometer != null)
        {
            _accelerometer.Shaken += _accelerometer_Shaken;
        }
    }

    async private void _accelerometer_Shaken(Accelerometer sender, AccelerometerShakenEventArgs args)
    {
        await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
            shakeCount++;
            tbInfo.Text = shakeCount.ToString();
        });

    }



我不明白为什么

I don't understand why

推荐答案

此功能尚未支持。

这是从官方示例代码摘录

This is an extract from the official sample code

https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Accelerometer

< STRONG>加速度摇活动

当您选择了震动事件选项启用按钮,应用
显示每个摇事件的累计数时间发生的事件
。 (该应用程序第一次递增事件计数,然后呈现
的最新值。)

When you choose the Enable button for the Shake Events option, the app displays the cumulative number of shake events each time an event occurs. (The app first increments the event count and then renders the most recent value.)

请注意动摇的事件在Windows中不支持10构建10240,所以
动摇事件将永远不会提高,但示例演示
到如何处理时,增加了对震动的支持活动。

Note that shake events are not supported in Windows 10 build 10240, so the Shaken event will never be raised, but the sample demonstrates how to handle the event when support for shake is added.

我做了一个测试的Windows 10下的10586,它仍然无法正常工作。

I made a test under Windows 10 10586 and it still does not work.

这篇关于在windows加速度事件动摇通用的应用程序无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆