我有完整的密码,但是在注册活动中,当使用电话号码注册时,应用拒绝发送密码。它将发送验证,但验证代码确实发出了。它将保持旋转而不会发出代码。我已经用控制台完成了Firebase,并在应用程序上复制并粘贴了json。
这是我的
package com.nawinlabz.quickcab.activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.ViewFlipper;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseException;
import com.google.firebase.FirebaseTooManyRequestsException;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.PhoneAuthCredential;
import com.google.firebase.auth.PhoneAuthProvider;
import com.google.gson.Gson;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.nawinlabz.quickcab.R;
import com.nawinlabz.quickcab.app.App;
import com.nawinlabz.quickcab.listeners.BasicListener;
import com.nawinlabz.quickcab.listeners.RegistrationListener;
import com.nawinlabz.quickcab.model.AuthBean;
import com.nawinlabz.quickcab.model.BasicBean;
import com.nawinlabz.quickcab.model.CountryBean;
import com.nawinlabz.quickcab.model.CountryListBean;
import com.nawinlabz.quickcab.model.RegistrationBean;
import com.nawinlabz.quickcab.net.DataManager;
import com.nawinlabz.quickcab.util.AppConstants;
import com.nawinlabz.quickcab.widgets.OTPEditText;
/* import com.digits.sdk.android.AuthCallback;
import com.digits.sdk.android.AuthConfig;
import com.digits.sdk.android.Digits;
import com.digits.sdk.android.DigitsAuthButton;
import com.digits.sdk.android.DigitsException;
import com.digits.sdk.android.DigitsSession;*/
public class RegistrationActivity extends BaseAppCompatNoDrawerActivity {
private static final String TAG = "SignUpActivity";
/* private DigitsAuthButton digitsButton;
private AuthCallback digitsCallback;
private AuthConfig authConfig;*/
private String phone;
private RegistrationBean registrationBean;
private ViewFlipper viewFlipper;
private EditText etxtName;
private EditText etxtPhone;
private EditText etxtEmail;
private EditText etxtPassword;
private LinearLayout llVerification;
private TextView txtVerificationLabel;
private Spinner spinnerCountryCodes;
private CountryListBean countryListBean;
private ArrayAdapter<String> adapterCountryCodes;
private ImageView ivFlag;
private OTPEditText etxtOne;
private OTPEditText etxtTwo;
private OTPEditText etxtThree;
private OTPEditText etxtFour;
private OTPEditText etxtFive;
private OTPEditText etxtSix;
private FirebaseAuth mAuth;
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;
private String mVerificationId;
private PhoneAuthProvider.ForceResendingToken mResendToken;
private boolean isVerificationEnabled;
private String otpCode;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
initViews();
if (getIntent().hasExtra("phone_number")) {
phone = getIntent().getStringExtra("phone_number");
registrationBean.setPhone(phone);
}
getSupportActionBar().setTitle("Register");
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_base, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
lytContent.performHapticFeedback (HapticFeedbackConstants.VIRTUAL_KEY);
// mVibrator.vibrate(25);
onHomeClick();
return true;
}
return super.onOptionsItemSelected(item);
}
private void initViews() {
registrationBean = new RegistrationBean();
viewFlipper = (ViewFlipper) findViewById(R.id.viewflipper_registration);
viewFlipper.setDisplayedChild(0);
llVerification = (LinearLayout) findViewById (R.id.ll_registration_mobile_otp);
txtVerificationLabel = (TextView) findViewById (R.id.txt_registration_mobile_otp_label);
spinnerCountryCodes = (Spinner) findViewById (R.id.spinner_registration_mobile_country_code);
countryListBean = AppConstants.getCountryBean();
Collections.sort(countryListBean.getCountries());
List<String> countryDialCodes = new ArrayList<>();
for (CountryBean bean : countryListBean.getCountries()) {
countryDialCodes.add(bean.getDialCode());
}
// adapterCountryCodes = ArrayAdapter.createFromResource(this, R.array.country_codes, android.R.layout.simple_spinner_item);
adapterCountryCodes = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, countryDialCodes);
adapterCountryCodes.setDropDownViewResource(R.layout.item_spinner);
spinnerCountryCodes.setAdapter(adapterCountryCodes);
ivFlag = (ImageView) findViewById (R.id.iv_registration_mobile_country_flag);
etxtName = (EditText) findViewById(R.id.etxt_registration_name);
etxtPhone = (EditText) findViewById(R.id.etxt_registration_phone);
etxtEmail = (EditText) findViewById(R.id.etxt_registration_email);
etxtPassword = (EditText) findViewById(R.id.etxt_registration_password);
etxtOne = (OTPEditText) findViewById(R.id.etxt_registration_mobile_one);
etxtTwo = (OTPEditText) findViewById(R.id.etxt_registration_mobile_two);
etxtThree = (OTPEditText) findViewById (R.id.etxt_registration_mobile_three);
etxtFour = (OTPEditText) findViewById (R.id.etxt_registration_mobile_four);
etxtFive = (OTPEditText) findViewById (R.id.etxt_registration_mobile_five);
etxtSix = (OTPEditText) findViewById(R.id.etxt_registration_mobile_six);
etxtOne.setTypeface(typeface);
etxtTwo.setTypeface(typeface);
etxtThree.setTypeface(typeface);
etxtFour.setTypeface(typeface);
etxtFive.setTypeface(typeface);
etxtSix.setTypeface(typeface);
etxtName.setTypeface(typeface);
etxtPhone.setTypeface(typeface);
etxtEmail.setTypeface(typeface);
etxtPassword.setTypeface(typeface);
etxtPassword.setTransformationMethod(new PasswordTransformationMethod ());
viewFlipper.setDisplayedChild(0);
mAuth = FirebaseAuth.getInstance();
setVerificationLayoutVisibility(false);
Glide.with(getApplicationContext())
.load("file:///android_asset/" + "flags/"
+ countryListBean.getCountries().get(0).getCountryCode ().toLowerCase() + ".gif")
.apply(new RequestOptions()
.centerCrop()
.circleCrop())
.into(ivFlag);
getSupportActionBar().hide();
swipeView.setPadding(0, 0, 0, 0);
spinnerCountryCodes.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Glide.with(getApplicationContext())
.load("file:///android_asset/" + "flags/"
+ countryListBean.getCountries().get (position).getCountryCode().toLowerCase() + ".gif")
.apply(new RequestOptions()
.centerCrop()
.circleCrop())
.into(ivFlag);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
Glide.with(getApplicationContext())
.load("file:///android_asset/" + "flags/"
+ countryListBean.getCountries().get (0).getCountryCode().toLowerCase() + ".gif")
.apply(new RequestOptions()
.centerCrop()
.circleCrop())
.into(ivFlag);
}
});
etxtOne.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength1 = etxtOne.getText().length();
if (textlength1 >= 1) {
etxtOne.setBackgroundResource (R.drawable.circle_white_with_app_edge);
etxtTwo.requestFocus();
} else {
etxtOne.setBackgroundResource (R.drawable.circle_white_with_gray_edge);
}
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
});
etxtTwo.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength2 = etxtTwo.getText().length();
if (textlength2 >= 1) {
etxtTwo.setBackgroundResource(R.drawable.circle_white_with_app_edge);
etxtThree.requestFocus();
} else {
etxtTwo.setBackgroundResource(R.drawable.circle_white_with_gray_edge);
}
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
});
etxtThree.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength3 = etxtThree.getText().length();
if (textlength3 >= 1) {
etxtThree.setBackgroundResource(R.drawable.circle_white_with_app_edge);
etxtFour.requestFocus();
} else {
etxtThree.setBackgroundResource(R.drawable.circle_white_with_gray_edge);
}
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
});
etxtFour.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Integer textlength4 = etxtFour.getText().toString().length();
if (textlength4 == 1) {
etxtFour.setBackgroundResource(R.drawable.circle_white_with_app_edge);
etxtFive.requestFocus();
} else {
etxtFour.setBackgroundResource(R.drawable.circle_white_with_gray_edge);
}
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
});
etxtFive.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Integer textlength4 = etxtFive.getText().toString().length();
if (textlength4 == 1) {
etxtFive.setBackgroundResource(R.drawable.circle_white_with_app_edge);
etxtSix.requestFocus();
} else {
etxtFive.setBackgroundResource(R.drawable.circle_white_with_gray_edge);
}
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
});
etxtSix.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Integer textlength4 = etxtSix.getText().toString().length();
if (textlength4 == 1) {
etxtSix.setBackgroundResource(R.drawable.circle_white_with_app_edge);
} else {
etxtSix.setBackgroundResource(R.drawable.circle_white_with_gray_edge);
}
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
});
etxtSix.setOnDeleteKeyClick(new OTPEditText.OnDeleteKeyClick() {
@Override
public void onDeleteKeyClick(boolean isPressed) {
int i = etxtSix.getText().toString().length();
if (i == 0) {
etxtFive.setText("");
etxtFive.requestFocus();
}
}
});
etxtFive.setOnDeleteKeyClick(new OTPEditText.OnDeleteKeyClick() {
@Override
public void onDeleteKeyClick(boolean isPressed) {
int i = etxtFive.getText().toString().length();
if (i == 0) {
etxtFour.setText("");
etxtFour.requestFocus();
}
}
});
etxtFour.setOnDeleteKeyClick(new OTPEditText.OnDeleteKeyClick() {
@Override
public void onDeleteKeyClick(boolean isPressed) {
int i = etxtFour.getText().toString().length();
if (i == 0) {
etxtThree.setText("");
etxtThree.requestFocus();
}
}
});
etxtThree.setOnDeleteKeyClick(new OTPEditText.OnDeleteKeyClick() {
@Override
public void onDeleteKeyClick(boolean isPressed) {
int i = etxtThree.getText().toString().length();
if (i == 0) {
etxtTwo.setText("");
etxtTwo.requestFocus();
}
}
});
etxtTwo.setOnDeleteKeyClick(new OTPEditText.OnDeleteKeyClick() {
@Override
public void onDeleteKeyClick(boolean isPressed) {
int i = etxtTwo.getText().toString().length();
if (i == 0) {
etxtOne.setText("");
etxtOne.requestFocus();
}
}
});
etxtSix.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (etxtOne.getText().toString().length() == 0) {
etxtOne.requestFocus();
} else if (etxtTwo.getText().toString().length() == 0) {
etxtTwo.requestFocus();
} else if (etxtThree.getText().toString().length() == 0) {
etxtThree.requestFocus();
} else if (etxtFour.getText().toString().length() == 0) {
etxtFour.requestFocus();
} else if (etxtFour.getText().toString().length() == 0) {
etxtFive.requestFocus();
}
}
}
});
etxtFive.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (etxtOne.getText().toString().length() == 0) {
etxtOne.requestFocus();
} else if (etxtTwo.getText().toString().length() == 0) {
etxtTwo.requestFocus();
} else if (etxtThree.getText().toString().length() == 0) {
etxtThree.requestFocus();
} else if (etxtFour.getText().toString().length() == 0) {
etxtFour.requestFocus();
}
}
}
});
etxtFour.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (etxtOne.getText().toString().length() == 0) {
etxtOne.requestFocus();
} else if (etxtTwo.getText().toString().length() == 0) {
etxtTwo.requestFocus();
} else if (etxtThree.getText().toString().length() == 0) {
etxtThree.requestFocus();
}
}
}
});
etxtThree.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (etxtOne.getText().toString().length() == 0) {
etxtOne.requestFocus();
} else if (etxtTwo.getText().toString().length() == 0) {
etxtTwo.requestFocus();
}
}
}
});