【发布时间】:2016-10-29 16:52:35
【问题描述】:
我正在为我的 Android 应用设置 GeoFire。在从 Firebase 数据库检索数据开始时,我收到以下异常。
获取 GeoFire 位置时出错:DatabaseError:从 Firebase 数据库运行循环调用的用户代码引发了异常: W/System.err:java.lang.Throwable:GeoFire 数据的格式无效:{lon=74.529964, lat=31.4479225}
显然,它正在从数据库中检索数据,但仍然抛出异常:(
我已使用以下代码检索数据:
geoFire.getLocation("test1", new LocationCallback() {
@Override
public void onLocationResult(String key, GeoLocation location) {
if (location != null) {
System.out.println(String.format("The location for key %s is [%f,%f]", key, location.latitude, location.longitude));
} else {
System.out.println(String.format("There is no location for key %s in GeoFire", key));
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
System.err.println("There was an error getting the GeoFire location: " + databaseError);
}
});
由于我是 firebase 新手,有什么明显的我遗漏的吗?This is how my firebase database looks like
【问题讨论】:
-
该错误消息听起来像是 GeoFire 认为数据库中的数据无效。请在您的问题中添加数据库是如何填充的。
-
@MichaelKarcher 我附上了数据库结构的屏幕截图。我已尝试检索 test1 和 test2 的数据。他们都给出了同样的错误
标签: android firebase firebase-realtime-database geofire