Skip to content Skip to sidebar Skip to footer

Why While Shifting From Productdetailsactivity To Homeactivity, A Toast Appears From The Loginactivity?

Please, help me solve this issue. I have working on this for days. ProductsDetailActivity package com.example.spree; import androidx.annotation.NonNull

Solution 1:

If anyone's viewed my question on kept on wondering why? I have found a solution (Yay!). In my LoginActivity I have written:

    myRef.addValueEventListener(newValueEventListener() {...

But I should have written instead:

    myRef.addListenerForSingleValueEvent(newValueEventListener() {...

Because addValueEventListener() keep listening to query or database reference it is attached to. But addListenerForSingleValueEvent() executes onDataChange method immediately and after executing that method once,it stops listening to the reference location it is attached to. Thus, problem has been resolved.

Post a Comment for "Why While Shifting From Productdetailsactivity To Homeactivity, A Toast Appears From The Loginactivity?"