这是我在Android应用程序中使用时间戳的firebase数据的简单查询
Query recentStaticJobQuery = reference.child(AppConstants.WORKINDIA_JOBS)
.child(AppConstants.WORKINDIA_STATIC_JOBS)
.orderByChild(AppConstants.TIMESTAMP)
.startAt(lastStaticJobSyncTime);
recentStaticJobQuery.addListenerForSingleValueEvent
(staticJobDownloadListener);
ValueEventListener staticJobDownloadListener = new ValueEventListener() {
@Override
public void onDataChange(final DataSnapshot dataSnapshot) {
Log.i("Firebase", "Called")
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.i("Firebase", "onCancelled")
}
};
Run Code Online (Sandbox Code Playgroud)
如何避免onDataChange在android Firebase中被调用两次?