【发布时间】:2019-05-28 22:45:33
【问题描述】:
我正在我的应用程序中设置当前位置。我需要在哪里设置编码?
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
//Geo Fire for current location
String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
DatabaseReference refAvailable = FirebaseDatabase.getInstance().getReference("driversAvailable");
DatabaseReference refWorking = FirebaseDatabase.getInstance().getReference("driversWorking");
GeoFire geoFireAvailable = new GeoFire(refAvailable);
GeoFire geoFireWorking = new GeoFire(refWorking);
switch (customerId){
case "":
geoFireWorking.removeLocation(userId);
geoFireAvailable.setLocation(userId, new GeoLocation(location.getLatitude(), location.getLongitude()), new GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {
}
});
break;
default:
geoFireAvailable.removeLocation(userId);
geoFireWorking.setLocation(userId, new GeoLocation(location.getLatitude(), location.getLongitude()), new GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {
}
});
break;
}
}
以下是我得到的错误:
java.lang.NoSuchMethodError: com.google.firebase.database.DatabaseReference.setValue 在 com.firebase.geofire.GeoFire.removeLocation(GeoFire.java:215) 在 com.firebase.geofire.GeoFire.removeLocation(GeoFire.java:192) 在 com.example.webforest.quickaidlikeuber2nd.DriverMapActivity.onLocationChanged(DriverMapActivity.java:184)
【问题讨论】:
-
你可以尝试使用
geoFire.setLocation(userId, new GeoLocation(location.getLatitude(), location.getLongitude()), new GeoFire.CompletionListener(){ });代替 -
成功了!!!!!!非常感谢
-
很高兴我能帮上忙...我会将其作为答案发布,以便将其从未回答的问题列表中删除。
标签: android dictionary firebase-realtime-database geofire currentlocation