Closed ProfessorDemo closed 4 years ago
we have only completed part 2 but we are getting issues. please HELP!!!!! this is our code
package com.example.hospitalapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast;
import com.google.firebase.FirebaseException; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.PhoneAuthCredential; import com.google.firebase.auth.PhoneAuthProvider; import com.rilixtech.widget.countrycodepicker.CountryCodePicker;
import java.util.concurrent.TimeUnit;
public class Register extends AppCompatActivity { public static final String TAG = "TAG"; EditText phoneNumber,codeEnter; FirebaseAuth fAuth; Button nextBtn; ProgressBar progressBar; TextView state; CountryCodePicker codePicker; String VerificationID; PhoneAuthProvider.ForceResendingToken token;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); fAuth = FirebaseAuth.getInstance(); phoneNumber = findViewById(R.id.phone); codeEnter = findViewById(R.id.codeEnter); progressBar = findViewById(R.id.progressBar); nextBtn = findViewById(R.id.nextBtn); codePicker = findViewById(R.id.ccp); nextBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(!phoneNumber.getText().toString().isEmpty() && phoneNumber.getText().toString().length()==10){ String phoneNum = "+"+codePicker.getSelectedCountryCode() + phoneNumber.getText().toString(); Log.d(TAG, "onClick: Phone NO -> "+ phoneNum); progressBar.setVisibility(View.VISIBLE); state.setText("Sending OTP"); state.setVisibility(View.VISIBLE); requestOTP(phoneNum); }else { phoneNumber.setError("Phone Number is not valid"); } } }); } private void requestOTP(String phoneNum) { PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNum, 60L, TimeUnit.SECONDS, this, new PhoneAuthProvider.OnVerificationStateChangedCallbacks() { @Override public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) { super.onCodeSent(s, forceResendingToken); progressBar.setVisibility(View.GONE); state.setVisibility(View.GONE); codeEnter.setVisibility(View.VISIBLE); VerificationID = s; token = forceResendingToken; } @Override public void onCodeAutoRetrievalTimeOut(String s) { super.onCodeAutoRetrievalTimeOut(s); } @Override public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) { } @Override public void onVerificationFailed(FirebaseException e) { Toast.makeText(Register.this,"Cannot Create Account" + e.getMessage(),Toast.LENGTH_SHORT).show(); } }); }
}
please share the log message when the app crashed.
we have only completed part 2 but we are getting issues. please HELP!!!!! this is our code
package com.example.hospitalapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast;
import com.google.firebase.FirebaseException; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.PhoneAuthCredential; import com.google.firebase.auth.PhoneAuthProvider; import com.rilixtech.widget.countrycodepicker.CountryCodePicker;
import java.util.concurrent.TimeUnit;
public class Register extends AppCompatActivity { public static final String TAG = "TAG"; EditText phoneNumber,codeEnter; FirebaseAuth fAuth; Button nextBtn; ProgressBar progressBar; TextView state; CountryCodePicker codePicker; String VerificationID; PhoneAuthProvider.ForceResendingToken token;
}