【发布时间】:2017-09-09 08:59:23
【问题描述】:
我正在使用 FirebaseUI 在我的应用中创建电话号码身份验证活动。缺省情况下,重发 OPT 的时间为 15 秒。我想改变这个时间限制。该怎么做?
public class PhoneNumberAuthentication extends AppCompatActivity {
private static final int RC_SIGN_IN = 123;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser() != null) {
// already signed in
startActivity(new Intent(PhoneNumberAuthentication.this, MainActivity.class));
finish();
} else {
// not signed in
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(
Arrays.asList(
new AuthUI.IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER).build()
))
.build(),
RC_SIGN_IN);
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// RC_SIGN_IN is the request code you passed into startActivityForResult(...) when starting the sign in flow.
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
// Successfully signed in
if (resultCode == ResultCodes.OK) {
startActivity(new Intent(PhoneNumberAuthentication.this,MainActivity.class));
finish();
return;
} else {
// Sign in failed
if (response == null) {
// User pressed back button
Log.e("Login","Login canceled by User");
return;
}
if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
Log.e("Login","No Internet Connection");
return;
}
if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
Log.e("Login","Unknown Error");
return;
}
}
Log.e("Login","Unknown sign in response");
}
}
}
我已附上 OPT 验证活动的屏幕截图:OTP Verification Activity。重新发送代码计时器从 15 开始倒计时,当它到达 0 时,它启用重新发送 OTP 按钮。我需要增加这个倒计时时间。
【问题讨论】:
-
得到了任何答案。提供的那个不起作用。
标签: android authentication firebase firebaseui