1

I have a background task and it is supposed to trigger when there is some change in position because it is set with Geofence trigger.

builder.SetTrigger(new LocationTrigger(LocationTriggerType.Geofence));

private static async Task<string> LocationUpdateHelper()
{
    try
    {
        var taskRegistered = false;
        string myTaskName = "LocationUpdateTask";
        foreach (var cur in BackgroundTaskRegistration.AllTasks)
            if (cur.Value.Name == myTaskName)
            {
                taskRegistered = true;
                break;
            }

        if (taskRegistered != true)
        {

            await BackgroundExecutionManager.RequestAccessAsync();
            var builder = new BackgroundTaskBuilder();

            builder.Name = "LocationUpdateTask";
            builder.TaskEntryPoint = "SmartRuntimes.LocationUpdateTask";
            builder.SetTrigger(new LocationTrigger(LocationTriggerType.Geofence));
            try
            {
                builder.Register();
                Debug.WriteLine("GeoFence Task Registered");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("GeoFence Task Failed : " + ex.Message.ToString());
            }
        }

        return "success";
    }
    catch (Exception ex)
    {
        return "";
    }
}

And LocationUpdateTask class is:

public sealed class LocationUpdateTask : IBackgroundTask
{
    public async void Run(IBackgroundTaskInstance taskInstance)
    {
        string taskName = taskInstance.Task.Name;
        var deferral = taskInstance.GetDeferral();
        await BackgroundTaskHelper.UpdateLocation();
        deferral.Complete();
    }
}

My question is:

  • Does this background task triggers when there is change in position?
  • How much distance needs to change for triggering that background task?

Thanks!

Chubosaurus Software
  • 8,133
  • 2
  • 20
  • 26
Kishor Bikram Oli
  • 1,748
  • 1
  • 22
  • 40

1 Answers1

1

Unfortunately Windows Phone 8.1 doesn't support continuous tracking in the background. If you want this feature you'll have to develop a Windows Phone 8 app instead. Hopefully they'll fix this for 8.2, 9 or whatever's next!

If you want to learn more about background task check here

chek it here also

Community
  • 1
  • 1
Kushal Maniyar
  • 846
  • 1
  • 8
  • 26