-1

My code is.

PhoneAuthProvider.getInstance().verifyPhoneNumber(
                        phoneno,        // Phone number to verify
                        60,                 // Timeout duration
                        TimeUnit.SECONDS,   // Unit of timeout
                        this,               // Activity (for callback binding)
                        mCallbacks);        // OnVerificationStateChangedCallbacks
            }
        });

After writing callbacks it shows error like this

Cannot resolve method verifyPhoneNumber(android.widgit.EditText,int,java.util.concurrent.TimeUnit,anonymous android.view.View.ONClickListener,come.google.firbase.auth.PhoneauthProvider.OnVerificationStateChangedCallbacks)

I have already defined mCallbacks. Can you please guide me with solution?

Ajay K S
  • 350
  • 1
  • 5
  • 16
  • The java classpath in your error mentions `come.google.firbase.auth.PhoneauthProvider.OnVerificationStateChangedCallbacks`. I would expect that should be `com.google...` not `come.google...` Your code references `PhoneAuthProvider` (correct) but the error has different lowercase `PhoneauthProvider`. I also think you have the wrong scope of the package imported, don't you want this: https://firebase.google.com/docs/reference/android/com/google/firebase/auth/PhoneAuthProvider – Davos Feb 06 '20 at 05:22

2 Answers2

1

You need to pass phoneno.getText().toString() as the first parameter.

For the second-last parameter, you are passing this, which refers to the anonymous inner class. You need to supply the reference of the containing activity class.

So change this
to MyActivity.this

(obviously replace "MyActivity" with your actual activity name)

Check documentation for all overloaded versions of verifyPhoneNumber method.

Also see What's the difference between this and Activity.this.

Kartik
  • 7,677
  • 4
  • 28
  • 50
0

As error message says you are passing edittext object instead of phone number -

verifyPhoneNumber(String phoneNumber, long timeout, TimeUnit unit, Activity activity, PhoneAuthProvider.OnVerificationStateChangedCallbacks callbacks)

as per method 1st param is string

try setting phoneno.getText().toString() -

PhoneAuthProvider.getInstance().verifyPhoneNumber(
                    phoneno.getText(),        // Phone number to verify
                    60,                 // Timeout duration
                    TimeUnit.SECONDS,   // Unit of timeout
                    this,               // Activity (for callback binding)
                    mCallbacks);        // OnVerificationStateChangedCallbacks
        }**strong text**
    });
Dipankar Baghel
  • 1,932
  • 2
  • 12
  • 24
  • now it shows android.text.Editable, then I tried '''phoneno.getText().toString''' and now it shows java.;ang.string – LEGENDARY GOKU Feb 06 '20 at 04:57
  • verifyPhoneNumber(String phoneNumber, long timeout, TimeUnit unit, Activity activity, PhoneAuthProvider.OnVerificationStateChangedCallbacks callbacks), Yeh you need to pass phoneNumber as string , second time unit that is correct, then Activity you should pass YourActivity.this then your callback. thats it. It should work – Dipankar Baghel Feb 06 '20 at 06:33