C# Xamarin交叉地理围栏过渡

C# Xamarin交叉地理围栏过渡,c#,xamarin,xamarin.android,C#,Xamarin,Xamarin.android,我在这里下载并安装了xamarin的CrossGeofence插件: 使用此处找到的样本作为指南: 我已经在我的物理手机LGE LG-D852(安卓6.0-API23)上进行了测试,并进行了usb调试 我的CrossGeofenceListener类已实现如下: public class CrossGeofenceListener : IGeofenceListener { //TODO: figure out what to do with this one. public

我在这里下载并安装了xamarin的CrossGeofence插件:

使用此处找到的样本作为指南:

我已经在我的物理手机LGE LG-D852(安卓6.0-API23)上进行了测试,并进行了usb调试

我的CrossGeofenceListener类已实现如下:

 public class CrossGeofenceListener : IGeofenceListener
{
    //TODO: figure out what to do with this one.
    public void OnAppStarted()
    {
        //throw new NotImplementedException();
    }        

    //copied from geofence sample
    public void OnError(string error)
    {
        Debug.WriteLine(string.Format("{0} - {1}: {2}", CrossGeofence.Id, "Error", error));
    }

    //TODO: figure out what needs to be done when the location changes.
    public void OnLocationChanged(GeofenceLocation location)
    {
        //throw new NotImplementedException();
    }

    //copied from geofence sample
    public void OnMonitoringStarted(string region)
    {
        Debug.WriteLine(string.Format("{0} - {1}: {2}", CrossGeofence.Id, "Monitoring in region", region));
    }

    //copied from geofence sample
    public void OnMonitoringStopped()
    {
        Debug.WriteLine(string.Format("{0} - {1}", CrossGeofence.Id, "Monitoring stopped for all regions"));            
    }

    //copied from geofence sample
    public void OnMonitoringStopped(string identifier)
    {
        Debug.WriteLine(string.Format("{0} - {1}: {2}", CrossGeofence.Id, "Monitoring stopped in region", identifier));            
    }

    //copied from geofence sample
    public void OnRegionStateChanged(GeofenceResult result)
    {            
        Debug.WriteLine(string.Format("{0} - {1}", CrossGeofence.Id, result.ToString()));
    }
}
我已经创建并开始监控围栏,例如:

 foreach (var facility in Facilities)
        {
            CrossGeofence.Current.StartMonitoring(new GeofenceCircularRegion(facility.Name, facility.Latitude, facility.Longitude, 2000)
            {
                NotifyOnStay = true,
                NotifyOnEntry = true,
                NotifyOnExit = true,
                ShowNotification = true,
                ShowEntryNotification = false,
                ShowExitNotification = false,
                ShowStayNotification = true,
                NotificationStayMessage = "stay message!",
                NotificationEntryMessage = "entry message!",
                NotificationExitMessage = "exit message!",
                StayedInThresholdDuration = TimeSpan.FromSeconds(1),                    
            });
        }

根据上面给出的信息,我只会弹出输入的geofence通知。我没有得到退出和停留的通知。关于如何触发停留和退出转换的任何建议?

使用另一个应用程序欺骗gps坐标后,它已开始正确报告停留和退出通知。我唯一的假设是,由于gps坐标变化不够剧烈,所以之前没有任何工作。

在使用另一个应用程序欺骗gps坐标后,它已开始正确报告停留和离开通知。我唯一的假设是,由于gps坐标变化不够剧烈,以前没有任何东西工作。

相应地,以下代码片段(在您的帖子中描述):


您应该收到停留通知,但不允许进入/退出,为了接收其中三个,请将适当的Show…通知设置为true。

相应地,根据以下代码片段(在您的帖子中描述):

您应该收到停留通知,但不允许进入/退出,为了接收其中三个通知,请将适当的Show…通知设置为true

            ShowEntryNotification = false,
            ShowExitNotification = false,
            ShowStayNotification = true,