activity reference in model

H

Hadi

Guest
I'm using MVVM pattern with firebase as a backend in my app. Firebase Phone authentication is present too and as it should it's placed in the model which is a singleton. The process of signing in needs an activity reference for callback binding but creating a reference to the activity might lead to memory leaks since it's in a singleton class and it's not generally a good practice as I doubt. Should I put this logic in the activity or is there a better approach for this?

That's the method that needs the activity reference:

void phoneLogin(String number) {

PhoneAuthProvider.getInstance().verifyPhoneNumber(
number, // Phone number to verify
1, // Timeout duration
TimeUnit.MINUTES, // Unit of timeout
----> activty // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks


}

Continue reading...
 
Top