1

I have to create a Background Task which should run after every 1 minute and should call a Rest service to update the Mobile longitude and Latitude Location. The rest service for this purpose have been written all I have to do is to write a Task in my existing application which should perform this update. Can you guys please tell which is the most easiest way to implement this functionality.

Thanks,

Ahmad.Masood
  • 1,289
  • 3
  • 21
  • 40
  • What have you tried? Have you look at [BackgroundAgents](http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202942(v=vs.105).aspx), especially Scheduled one? – Romasz Feb 17 '14 at 11:05
  • 2
    MSDN covers this well in a series of tutorials: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662935(v=vs.105).aspx – WiredPrairie Feb 17 '14 at 12:55

1 Answers1

3

There isn't a concept of a service like exists in Windows Desktop. Applications are running, or not on the phone. One application on the phone, tracking location, can be running in the background while other applications run.

If your application is in the foreground, you will just directly call the web services with updated location.

You can use a scheduled background agent to periodically update location, but it is likely that it won't update frequently enough for your needs.

MSDN has details about how to create an application that actively tracks location in the background, subject to some important limitations, and reasons the application may be deactivated:

  • The app stops actively tracking location. An app stops tracking location by removing event handlers for the PositionChanged and StatusChanged events of the Geolocator class or by calling the Stop() method of the GeoCoordinateWatcher class.
  • The app has run in the background for 4 hours without user interaction.
  • Battery Saver is active.
  • Device memory is low.
  • The user disables Location Services on the phone.
  • Another app begins running in the background.

In addition, there is a complete tutorial available for this scenario.

WiredPrairie
  • 58,954
  • 17
  • 116
  • 143
  • This is an application which run completely in background.I don't want this to happen. I have an existing application which have a UI. I have to integrate this functionality with that app. You can say that i want a thread to run and perform this task but that thread should be independent of rest of application. – Ahmad.Masood Feb 17 '14 at 13:10
  • 1
    I added a little more detail. If your application is in the foreground, you would just call the API you've built. – WiredPrairie Feb 17 '14 at 13:18