我曾尝试建立实时租车服务,但我得到此错误,返回null的datasnapshot,并尝试了所有修复问题,但没有成功 我不知道问题出在哪里,为什么我的数据库不响应请求
DatabaseReference driverLocation = FirebaseDatabase.getInstance().getReference(Common.driver_location_tbl);
GeoFire gf = new GeoFire(driverLocation);
GeoQuery geoQuery = gf.queryAtLocation(new GeoLocation(mLastLocation.getLatitude(),mLastLocation.getLongitude()),distance);
geoQuery.removeAllListeners();
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() {
@Override
public void onKeyEntered(final String key, final GeoLocation location) {
FirebaseDatabase.getInstance().getReference(Common.driver_tbl)
.child(key)
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Rider rider = dataSnapshot.getValue(Rider.class);
mMap.addMarker(new MarkerOptions()
.position(new LatLng(location.latitude,location.longitude))
.flat(true)
.title("Driver Name :"+rider.getUsername())
.snippet("Phone : "+rider.getPhone())
.icon(BitmapDescriptorFactory.fromResource(R.drawable.cars)));
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
和我的Rider班
public class Rider {
private String email,password,phone,username;
public Rider() {
}
public Rider(String email, String password, String phone, String username) {
this.email = email;
this.password = password;
this.phone = phone;
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
如何修复应用程序漏洞并返回null的数据快照? 我正在研究修复方法,但没有发现任何东西。
答案 0 :(得分:0)
好,我修复了它 问题是我用不Uid的名称注册用户,所以当我请求名称和电话得到n
时