/// <summary> /// Constructor /// </summary> public MainPage() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Required; Window.Current.VisibilityChanged += async(oo, ee) => { if (!ee.Visible && _activityMonitor != null) { await CallSenseApiAsync(async() => { await _activityMonitor.DeactivateAsync(); }); await CallSenseApiAsync(async() => { await _stepCounter.DeactivateAsync(); }); } else if (_activityMonitor != null) { await CallSenseApiAsync(async() => { await _activityMonitor.ActivateAsync(); }); await CallSenseApiAsync(async() => { await _stepCounter.ActivateAsync(); }); // Refresh screen await UpdateScreenAsync(); } }; }
/// <summary> /// Re-establishes the communication channel with underlying sensor, if it doesn't /// already exist. Connection needs to be re-established when the application /// is brought to foreground. /// </summary> /// <returns>Returns an IAsyncAction object that is used to control the asynchronous operation.</returns> public async Task ActivateAsync() { if (_aMonitor != null) { await _aMonitor.ActivateAsync(); } if (_sCounter != null) { await _sCounter.ActivateAsync(); } if (_rTracker != null) { await _rTracker.ActivateAsync(); } if (_pMonitor != null) { await _pMonitor.ActivateAsync(); } }