How to run application in background in Windows Ph

2020-01-27 05:52发布

问题:

I want to develop a background application in Windows Phone 8. Like there is a flash screen and after the flash screen starts, immediately it would be moved to back ground.

But the timer present in the application should be active from being in background and keep doing the task assigned. So, in the fore ground user can continue using the device and in background the app will run a timer and continue with the tasks.

I have tried using Periodic tasks, but they get triggered once in 30 minutes and more. But I want this app to be triggered once in 20 seconds.

Kindly help me with some ideas.

回答1:

WP7/WP8 don't allow for full multitasking in the background for arbitrary apps. Whatever it is you're trying to accomplish will either have to be achieved in some other way or just not done on windows phone. There's lots of alternative as you've found out: WP7.5 Alarms & Reminders, WP7 Scheduled Tile updates, WP7.5 Periodic Background Agents, Resource Intensive Background Agents, WP8 Geolocation tracking apps, WP7 Push Notifications and more.

The zen of WP7/8 Multitasking is to keep phones healthy both from a battery perspective, memory usage perspective and other resources as well. So, no full background multitasking. Although WP8 improves there with Geolocation tracking apps and Fast Application Resume.



回答2:

Windows Phone supports single MainApplication View and Background agents. If you want to do any application like "screenrecording" it is not possible because of security reason and because of battery reason. But if you are able to make your own Webservice, it should be easy to catch the situation by streaming data via Streaming agent.

Here some sample of agents.

Microsoft.Phone.BackgroundTransfer Namespace

Adding a Windows Phone Background Agent to an XNA Game

Windows Phone 7 Background Agents (CSWP7ScheduledTaskAgent)



回答3:

For exemple: https://code.msdn.microsoft.com/windowsapps/Background-sensors-eb7bb176

you need create an new project from template "Windows Runtime Component"

sorry my English.



回答4:

You could enable or disable applications to run in background:

Goto Settings > battery saver > usage > tap on application > On/Off Background

Few applications are always runnable in background by default, for whose it's disabled like Phone, FB Messenger, etc. If you really feel that, it should be in background, better please uninstall it.

Hope it helps.