当前位置: 代码迷 >> Windows Mobile >> WP7 程序在鎖屏後依然能夠運作
  详细解决方案

WP7 程序在鎖屏後依然能夠運作

热度:319   发布时间:2016-04-25 07:22:20.0
WP7 程序在鎖屏後仍然能夠運作
我现在 写了一个SHAKE DETECTOR
当用家摇电话一下,画面的数字会自动加1

现在只能在 运行情况才能加1, 只要一锁屏, 用户怎摇 数字都不会增加
数字只会在 运行情况才能加1。


我的APP 源码在:
namespace ShakeTest
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        private ShakeDetector _shakeDecetor;
        int co = 0;
        public MainPage()
        {
            PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
            PhoneApplicationFrame rootFrame = App.Current.RootVisual as PhoneApplicationFrame;
            if (rootFrame != null)
            {
                rootFrame.Obscured += new EventHandler<ObscuredEventArgs>(rootFrame_Obscured);
                rootFrame.Unobscured += new EventHandler(rootFrame_Unobscured);
            }

            InitializeComponent();
            _shakeDecetor = new ShakeDetector();
            _shakeDecetor.ShakeEvent += new EventHandler<EventArgs>(_shakeDecetor_ShakeEvent);
            _shakeDecetor.Start();
          
        }

        void _shakeDecetor_ShakeEvent(object sender, EventArgs e)
        {
            this.Dispatcher.BeginInvoke(() =>
                                          {
                                                count.Text = Convert.ToString(co);
  相关解决方案