Перед тем, как вы попросите меня попробовать наиболее распространенные исправления, я уже пробовал импортировать java.util.concurrent.TimeUnit
и пытался «аннулировать кэш / перезапуск» моего проекта.
package com.example.pstiwari;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.PhoneAuthProvider;
import com.hbb20.CountryCodePicker;
import java.util.concurrent.TimeUnit;
public class PhoneLoginActivity extends AppCompatActivity {
private EditText phoneText;
private TextView phoneText2;
private String phoneVerificationID;
private PhoneAuthProvider.OnVerificationStateChangedCallbacks verificationCallbacks;
private PhoneAuthProvider.ForceResendingToken resendToken;
String number;
private Button SendVerificationCodeButton, VerifyButton;
private EditText InputVerificationCode;
CountryCodePicker ccp;
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_phone_login);
SendVerificationCodeButton = (Button) findViewById(R.id.send_ver_code_button);
VerifyButton = (Button) findViewById(R.id.verify_button);
phoneText = (EditText) findViewById(R.id.phoneText);
InputVerificationCode = (EditText) findViewById(R.id.verification_code_input);
phoneText2 = (TextView) findViewById(R.id.textView);
ccp = (CountryCodePicker) findViewById(R.id.ccp);
ccp.registerCarrierNumberEditText(phoneText);
mAuth = FirebaseAuth.getInstance();
SendVerificationCodeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SendVerificationCodeButton.setVisibility(View.INVISIBLE);
phoneText.setVisibility(View.INVISIBLE);
phoneText2.setVisibility(View.INVISIBLE);
VerifyButton.setVisibility(View.VISIBLE);
InputVerificationCode.setVisibility(View.VISIBLE);
String phoneNumber = phoneText.getText().toString();
if (TextUtils.isEmpty(phoneNumber))
{
Toast.makeText(PhoneLoginActivity.this, "Please Enter Phone Number...", Toast.LENGTH_LONG).show();
}
else
{
number = ccp.getFullNumberWithPlus();
PhoneAuthProvider.getInstance().verifyPhoneNumber(
number, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
PhoneLoginActivity.this, // Activity (for callback binding)
verificationCallbacks); // OnVerificationStateChangedCallbacks
}
}
});
}
}