【发布时间】:2017-07-18 15:38:48
【问题描述】:
我创建了位置跟踪应用程序。今天我还添加了地理围栏功能。 I 是一个简单的单例类,当地理位置在给定坐标附近时会引发事件。
当我手动引发事件时,它会按预期工作。但是,当我在达到坐标时设置为释放模式时,它会停止应用程序。我里面有错误日志,写的是: java.lang.reflect.InvocationTargetException
我正在使用 MVVMCross 库。我的视图模型附加到地理围栏服务类女巫回调。当用户到达坐标时,应该调用回调。正如我在调试中所说,它正在工作。
以下代码示例:
public class GeofenceService : IGeofenceService
{
//...
public event EventHandler<GeofenceStatusChangedEventArgs> StatusChanged;
//..
}
public abstract class GeofenceViewModel : BaseViewModel
{
protected IGeofenceService GeofenceService { get; }
protected virtual void StartMonitoring(AddressModel address, MonitoringRadius radius)
{
MonitoredAddress = address;
GeofenceService.StartMonitoring(new Location(address.Id, address.Latitude, address.Longitude), radius, GeofenceExpectation);
GeofenceService.Subscribe(this, OnStatusChanged);
}
protected void OnStatusChanged(object sender, GeofenceStatusChangedEventArgs e)
{
//...
}
}
有没有办法获得真正的异常?
【问题讨论】:
标签: c# android exception xamarin