2017-11-01 1 views
0

좋은 날 firebase를 사용하여 새 계정을 등록하려고하지만 실행되지 않는 onComplete 메소드 오류가 있는지 확인하려고했습니다. 중단 점별로 하지만 it..as에 도달 결코 잘 나는 여기 내 코드입니다 .. 는 중포 기지 콘솔에서 사용할 수있는 비밀번호하지 미만 6 문자, 이메일/암호 확인 확인을 시도Firebase : createUserWithEmailAndPassword의 onComplete()가 실행되지 않음 ,,

 public class CreateAccountActivity extends AppCompatActivity { 

    private EditText emailedittxt; 
    private EditText passwordedittext; 
    private Button signUp; 
    //private EditText nametext; 
    private static final String TAG = "EmailPassword"; 
    //Authentication 
    private FirebaseAuth mAuth; 

    // public static Intent newIntent(Context packageContext){ 
//  Intent intent = new Intent(packageContext,CreateAccountActivity.class); 
//  return intent; 
// } 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_create_account); 

     mAuth = FirebaseAuth.getInstance(); 

//  nametext = (EditText) findViewById(R.id.RnameText); 
     emailedittxt = (EditText) findViewById(R.id.RemailText); 
     passwordedittext = (EditText) findViewById(R.id.RpasswordText); 
     signUp = (Button) findViewById(R.id.RsignupButton); 
     signUp.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       // signUp(); 
       //create new Account 
//    String name = nametext.getText().toString(); 
       String email = emailedittxt.getText().toString(); 
       String password = passwordedittext.getText().toString(); 
       //validate the felids 

//    if (TextUtils.isEmpty(name)) { 
//     Toast.makeText(CreateAccountActivity.this, "Enter your nmae", Toast.LENGTH_SHORT).show(); 
//     return; 
//    } 
       if (TextUtils.isEmpty(email)) { 
        Toast.makeText(CreateAccountActivity.this, "Enter your email", Toast.LENGTH_SHORT).show(); 
        return; 
       } 
       if (TextUtils.isEmpty(password)) { 
        Toast.makeText(CreateAccountActivity.this, "Enter your password", Toast.LENGTH_SHORT).show(); 
        return; 
       } 

       /*Create 
       new account */ 

       SignUp(email,password); 

      } 
     }); 
    } 
    private void SignUp(String email,String password) { 
     mAuth.createUserWithEmailAndPassword(email, password) 


       .addOnCompleteListener(CreateAccountActivity.this, new OnCompleteListener<AuthResult>() { 
        @Override 
        public void onComplete(@NonNull Task<AuthResult> task) { 
         Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful()); 
//      // Toast.makeText(CreateAccountActivity.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show(); 
         // If sign in fails, display a message to the user. If sign in succeeds 
         // the auth state listener will be notified and logic to handle the 
//      // signed in user can be handled in the listener. 
         if (task.isSuccessful()) { 

          Intent intent = new Intent (CreateAccountActivity.this,Main2Activity.class); 
          startActivity(intent); 
          // startActivity(new Intent(CreateAccountActivity.this, Main2Activity.class)); 
          finish(); 

         } else { 
          Log.d(TAG, "onComplete: Failed=" + task.getException().getMessage()); //ADD THIS 
// 
////       Toast.makeText(CreateAccountActivity.this, "Authentication failed." + task.getException(), Toast.LENGTH_SHORT).show(); 

         }} 
       }); 
    } 
} 

누구나 그것이 왜 네바다인지 알 수 있습니다. 어 onComplete를 실행()

+0

모든 인증 실패 MSG? – Shruti

+0

@labon 무엇이 logcat에 표시됩니까? –

+0

Opps 나는 여분의 것을 설치하지 않고 물리적 장치에서 작동해야합니다. @PeterHaddad – labon

답변

0

시도 onFailureListener() 추가 : 로그 캣에서

private void SignUp(String email,String password) { 
    mAuth.createUserWithEmailAndPassword(email, password) 


      .addOnCompleteListener(CreateAccountActivity.this, new OnCompleteListener<AuthResult>() { 
       @Override 
       public void onComplete(@NonNull Task<AuthResult> task) { 
        Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful()); 
    //      // Toast.makeText(CreateAccountActivity.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show(); 
        // If sign in fails, display a message to the user. If sign in succeeds 
        // the auth state listener will be notified and logic to handle the 
//      // signed in user can be handled in the listener. 
        if (task.isSuccessful()) { 

         Intent intent = new Intent (CreateAccountActivity.this,Main2Activity.class); 
         startActivity(intent); 
         // startActivity(new Intent(CreateAccountActivity.this, Main2Activity.class)); 
         finish(); 

        } else { 
         Log.d(TAG, "onComplete: Failed=" + task.getException().getMessage()); //ADD THIS 
// 
////       Toast.makeText(CreateAccountActivity.this, "Authentication failed." + task.getException(), Toast.LENGTH_SHORT).show(); 

        }} 
      }).addOnFailureListener(new OnFailureListener() { 
      @Override 
      public void onFailure(@NonNull Exception e) { 
       Log.e("exception",e.getMessage()); 
      } 
     }); 
}