【发布时间】:2017-07-07 18:18:23
【问题描述】:
我已经使用 geofire 在实时数据库中保存了我的位置坐标,即在每 3 秒后更新一次的 firebase 现在我想检索我的地图活动中的坐标,即(纬度和经度),但我不知道如何检索它 。我是安卓工作室的新手 here is database pic how the location is saved
我在火力基地中存储位置的方法
public void onLocationChanged(Location location) {
FirebaseUser user = fb.getCurrentUser();
GeoFire geoFire = new
GeoFire(databaseReference.child(user.getUid()));
geoFire.setLocation("location", new
GeoLocation(location.getLatitude(), location.getLongitude()), new
GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {
if (error != null) {
Toast.makeText(gpdfuel.this, "There was an error
saving the location to GeoFire: " + error, Toast.LENGTH_LONG).show();
} else {
Toast.makeText(gpdfuel.this, "Location saved on server
successfully!", Toast.LENGTH_LONG).show();
}
}
});
这是保存位置的数据库图片
【问题讨论】:
-
你能不能多说明一下
-
你必须实现接口并使用其中的方法。类似于您使用 onLocationChanged 的方式。而不是你必须在这些方法中读取数据。喜欢在这里阅读firebase.google.com/docs/database/android/read-and-write。会有类似 geoFire.getLocation() 的方法
标签: android firebase firebase-realtime-database