我想从 Firebase 获取 OTP 到我的手机以进行验证,我已经按照文档所述完成了所有操作,但最后我没有得到 OTP 请帮助我,我知道我的代码有问题,任何人都可以纠正我吗?我的应用程序已连接并使用 firebase 这是我的活动 java 代码:
public class LoginActivity extends AppCompatActivity {
String phone_number;
FirebaseAuth auth;
PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks(){
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
}
@Override
public void onVerificationFailed(FirebaseException e) {
}
};
CardView card_view = findViewById(R.id.cardView);
card_view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText phonetextview = findViewById(R.id.phonetextview);
phone_number = PhoneNumberUtils.formatNumber(phonetextview.getText().toString());
send();
Toast toast = Toast.makeText(getApplicationContext(), phone_number,
Toast.LENGTH_SHORT);
toast.show();
}
});
}
private void send() {
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phone_number, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // ForceResendingToken from callbacks
}
}
拉莫斯之舞
繁花如伊
相关分类