Windows Phone 8.1 Backgroundtask中的位置触发器不会触发

时间:2015-10-01 11:13:59

标签: c# windows-phone-8.1 location background-task

我正在使用Windows Phone 8.1 [RT]应用程序,因为我在后台有更新位置,我正在使用GeofenceMonitor

 GeofenceMonitor gm = GeofenceMonitor.Current;
  gm.Geofences.Clear();
  Geoposition geoposition = await new Geolocator().GetGeopositionAsync();
  Geofence gf = new Geofence("InitalLocation", new Geocircle(geoposition.Coordinate.Point.Position, 1), MonitoredGeofenceStates.Entered | MonitoredGeofenceStates.Exited, false,TimeSpan.FromSeconds(5));
  gm.Geofences.Add(gf);

并为位置触发添加Backgroud任务

        var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync();
        var geofenceTaskBuilder = new BackgroundTaskBuilder
        {
            Name = "GeofenceBackgroundTask",
            TaskEntryPoint = "BackgroundTask.GeofenceBackgroundTask"
        };

        var trigger = new LocationTrigger(LocationTriggerType.Geofence);
        geofenceTaskBuilder.SetTrigger(trigger);
        var geofenceTask = geofenceTaskBuilder.Register();

我不知道我错在哪里,但当我在1米无线电中的位置时,后台任务不会触发。

找到参考代码here

0 个答案:

没有答案