dargod
dargod

Reputation: 332

Background the app programmatically

Does anyone know if there is a way to background Windows Phone/Windows Universal app in code?

I know it's possible to close the app from code but I would prefer to send it to background instead.

Thanks!

Upvotes: 0

Views: 243

Answers (1)

Scavenger
Scavenger

Reputation: 205

It is impossible to background a Windows store app in code. As well windows doesn't support a foreground App runs background. A universal Windows app only have three statues: Running, Suspended and Not Running. Referring to the official document we may see an app lifecycle:

enter image description here

An app can be activated by the user through a variety of extensions and contracts such as the Share contract.After the app completes activation, it enters the Running state and the splash screen disappears.

When the user moves an app to the background, Windows waits a few seconds to see whether the user will immediately switch back to the app so that the transition will be fast if they do. If the user does not switch back within this time window, Windows suspends the app.

After an app has been closed by the user, it's first suspended and then terminated, and enters the NotRunning state. Generally, users don't need to close apps, they can let Windows manage them. However, users can choose to close an app using the close gesture or by pressing Alt+F4 on Windows or by using the task switcher on Windows Phone.

The official document recommends that apps not close themselves programmatically. For example, If an app detects a memory leak, it will be terminated by system to ensure the security of the user's personal data. When you close an app programmatically, the system treats it as an app crash.

Upvotes: 2

Related Questions