1
votes

I want to implement an application for Windows Phone 8 in order to get and send the device location data to a server every minute.

For that I have followed this example:

http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662935(v=vs.105).aspx

Instead of using:

App.Geolocator.MovementThreshold = 100;

I use:

App.Geolocator.ReportInterval = 1 *60 * 1000;

The app works well in foreground.

If I press START button the app works well too but with the following limitations:

  1. If I open another appication, the backgroud gps tracker stop working.
  2. After one hour aproximately, or more, the background gps tracker stop working too.

I have read that apps running in background can be deactivated by the system due the some factors:

http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681691(v=vs.105).aspx

Is there any way or a strategy to assure my gps tracker keep working in background under the above two conditions? Currently is there any wp8 application working under this conditions? It is possible or not to do this in wp8?

1

1 Answers

3
votes

You must add this snippet in WMAppManifest.xml in order to keep GPS running in background:

   <Tasks>
       <DefaultTask Name="_default" NavigationPage="GUI/Register.xaml">
          <BackgroundExecution>
             <ExecutionType Name="LocationTracking" />
          </BackgroundExecution>
       </DefaultTask>
   </Tasks>     

Add this to be able to run app in background after 1hr at last line of App():

PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;

Hope this helps.