-1

In windows phone we had some life cycles that aren't available in UWP.

The application that I develop communicate over Bluetooth. At the moment, I communicate with the Bluetooth device every 1 minute. However when the user switches to another application or just turn the screen off (and the application is still running) I would like the communication to communicate every 10 minutes.

However, when I switch between applications, or even turn the screen off, the OnSuspending isn't being fired.

Is there any other way I can detect application switch or screen turned off.

I know this question has no code attached to it, however I investigated the UWP life cycles, but the solution wasn't in there.

Thx

eitan barazani
  • 1,123
  • 3
  • 18
  • 34

1 Answers1

1

While debugging the suspending event won't be fired, due to disabled PLM. You will have to invoke it manually from lifecycle tab. Normally, when you run without debugger attached, it will be fired up to few seconds after you left the app - lock screen, switch app, etc.

For your purposes the Suspending event will be the best, IMHO. Otherwise you may also think of Window.Current.VisibilityChanged and Window.Current.Activated - but those two doesn't have deferals and can be fired in other situations, not only the ones you have mentioned.

Community
  • 1
  • 1
Romasz
  • 29,662
  • 13
  • 79
  • 154