Domanda

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,

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top