任何人都可以帮助我,为什么这是一个错误?当我单击send otp时,我正在在Android上进行OTP,之后出现错误,并且似乎未发送otp代码。
Mainactivity.java
public class MainActivity extends AppCompatActivity {
private Button submitBtn;
private EditText phoneText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
submitBtn = findViewById(R.id.submit);
phoneText = findViewById(R.id.phone_text);
buttonSubmitListener();
}
private void buttonSubmitListener() {
submitBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO : Cek string edittext kosong atau tidak
if (!phoneText.getText().toString().isEmpty()) {
if (phoneText.getText().toString().charAt(0) == '0') {
String temp = "+62" + phoneText.getText().toString().substring(1);
// TODO : Passing phone number ke OTP Activity
Bundle bundle = new Bundle();
Intent intent = new Intent(MainActivity.this, OtpActivity.class);
bundle.putString("phone", temp);
intent.putExtras(bundle);
startActivity(intent);
}
} else {
Toast.makeText(MainActivity.this, "Masukkan nomor telpon", Toast.LENGTH_SHORT).show();
}
}
});
}
}
Otpactivity.java
私有PhoneAuthProvider.OnVerificationStateChangedCallbacks回调(){
return new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
Log.e("onVerificationCompleted", phoneAuthCredential.getSmsCode());
}
@Override
public void onVerificationFailed(FirebaseException e) {
if (e instanceof FirebaseAuthInvalidCredentialsException) {
Log.e("invalidCredential",e.toString());
} else if (e instanceof FirebaseTooManyRequestsException) {
Log.e("out of quota", e.toString());
}
}
@Override
public void onCodeAutoRetrievalTimeOut(String s) {
super.onCodeAutoRetrievalTimeOut(s);
Log.e("", s);
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(verificationId, forceResendingToken);
Log.e("","onCodeSent:" + verificationId);
mVerificationId = verificationId;
mResendToken = forceResendingToken;
}
};
}