How do I resolve Activity (for callback binding)?

Viewed 146

I a not an experienced app developer. please forgive me for this question. I am trying to add firebase OTP into my app. I got stuck at

 PhoneAuthOptions options =
                PhoneAuthOptions.newBuilder(mAuth)
                        .setPhoneNumber("number")       // Phone number to verify
                        .setTimeout(60L, TimeUnit.SECONDS) // Timeout and unit
                        .setActivity(this)                 // Activity (for callback binding)
                        .setCallbacks(mCallbacks)          // OnVerificationStateChangedCallbacks
                        .build();
        PhoneAuthProvider.verifyPhoneNumber(options);

what is .setActivity(this)? What I am supposed to do here?? This is the full code link: https://www.codepile.net/pile/MR8YdA3k

and error screenshot enter image description here

3 Answers
PhoneAuthOptions options =
                PhoneAuthOptions.newBuilder(mAuth)
                        .setPhoneNumber("number")       // Phone number to verify
                        .setTimeout(60L, TimeUnit.SECONDS) // Timeout and unit
                        .setActivity(getActivity())                 // Activity (for callback binding)
                        .setCallbacks(mCallbacks)          // OnVerificationStateChangedCallbacks
                        .build();
        PhoneAuthProvider.verifyPhoneNumber(options);

Listen this callback in the fragment's activity.

The class named 'Phone_F' should be an activity, not a fragment. That means the 'Phone_F' class should extend an activity instead of a fragment. Follow this link for details. And let me know if I could be any more help. Happy coding.

Related