从Firebase接收数据时,我面临一个很大的问题。 我想要一种方法来接收目标,而其他方法来接收用户位置。
这是我的代码:
private DatabaseReference mDatabase,mDatabase2;
LocationHelper locationHelpry;
protected void onCreate(Bundle savedInstanceState) {
mDatabase = FirebaseDatabase.getInstance().getReference().child("users");
mDatabase2 = FirebaseDatabase.getInstance().getReference("users").child("targets");
ReceiveTargets();
RecieveLocation();
}
private void ReceiveTargets(){
Log.i("ttt","1st created");
mDatabase2.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Log.i("ttt","2nd Created");
for (DataSnapshot ds: dataSnapshot.getChildren()){
LocationHelper locationHelper = new LocationHelper();
locationHelper = ds.getValue(LocationHelper.class);
Log.i("ttt", "rrr"+ds.getChildrenCount());
}
}
}
}
错误正在显示:
E/Zygote: accessInfo : 1
E/Zygote: isWhitelistProcess - Process is Whitelisted
我的清单:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />