Frage

Currently I am migrating WP8 app into WP8.1 Universal app, In WP8 app I am using Background task using Geoposition Changed event. Whenever user position changed the code will get fired. I am confused totally after seeing the Background task implementation in Win RT apps and in WinRT apps background tasks will get fired only when a particular trigger triggers. Can any one help me how to achieve to run the code when geoposition changed throung background task.

Thanks in Advance.

Narendra

War es hilfreich?

Lösung

Seen this extensive sample for Windows/Phone apps?

http://code.msdn.microsoft.com/wpapps/Geolocation-2483de66

Andere Tipps

You are right, background tasks can run based on timer triggers and you can set it to run every 15 minutes.

Here's how background tasks work. The process is you register a background task and set a time for the periodic occurrence. On windows phones you cannot do any processing while the application is not in the foreground apart from using the background task API.

The Background task entry point that you will register in your application should implement IBackgroundTask interface which has a RUN function and this is the function that is triggered each time a background task is encountered. That is where you will have your code. So essentially, your geoposition changed event should be in this function.

Every 15 minutes your geoposition changed event is triggered automatically and you can store that in a window.storage local setting or you can send a popup notification etc....

Please note, that the background task should be a windows runtime project only.

Here's a sample code that i have which will help you to start off. Use this code and all you need to do is add a event handler in the TimerTrigger.cs class under the Tasks project. If you want you can fork it and send me a pull request as well.

https://github.com/vinayganesh/Wp8.1BackgroundTask

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top