Skip to content Skip to sidebar Skip to footer

Android Using Firebaseui With Firebaselistoptions To Populate A Listview Doesn't Call Populateview

I'm using the following dependencies in build.gradle: compile 'com.google.firebase:firebase-database:11.4.2' compile 'com.firebaseui:firebase-ui-database:3.1.0' compile 'com.fireba

Solution 1:

I had the same problem, fixed it with:

@OverrideprotectedvoidonStart() {
    super.onStart();
    mAdapter.startListening();
}

And then

@OverrideprotectedvoidonStop() {
    super.onStop();
    mAdapter.stopListening();
}

Works like it did before the update :-)

Solution 2:

I had the same problem. I tried the accepted answer, but the code was failing with null pointer exception in the startListening statement (adapter was null !).

After much research, I added .setLifecycleOwner(this) as in the sample code (see below code for example). It worked like a charm!

FirebaseListOptions<Message> options = new FirebaseListOptions.Builder<Message>()
    .setLayout(R.layout.fbmessage_listitem)//Note: The guide doesn't mention this method, without it an exception is thrown that the layout has to be set.
    .setQuery(query, Message.class)
    .setLifecycleOwner(this)   //Added this
    .build();

Solution 3:

Could it be a typo in the query? notifications instead of notification? Try putting a breakpoint in FirebaseListAdapter#onChildChanged() and see if any events come in.

Most likely, it's because you haven't called FirebaseListAdapter#startListening(). Unless you are using Android Architecture Components with FirebaseListOptions#setLifecycleOwner(...), you must manually manage your adapter's lifecycle. This means calling startListening() in onStart() and stopListening() in onStop().

PS: I would recommend checking out the RecyclerView which has better performance than ListView.

Post a Comment for "Android Using Firebaseui With Firebaselistoptions To Populate A Listview Doesn't Call Populateview"