I am very new to Android and a high school student. So I think it'd be nice if you could give me the code, too. I implemented login using firebase and LoginActivity.FragmentIndivative in java.I want to send my name, e-mail address, and phone number to java. So I used a Bundle object, and NullpointerException occurred. Please help me. I don't have time. I'll wait for you guys. I'll attach the code below. Please take good care of me.
private void signUp(){
final String email = ((EditText)findViewById(R.id.idText)).getText().toString();
final String password = ((EditText)findViewById(R.id.pwText)).getText().toString();
if(email.length() > 0 && password.length() > 0){
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Intent intent1;
if (task.isSuccessful()) {
FirebaseUser user = mAuth.getCurrentUser();
startToast("로그인에 성공하였습니다");
fragmentIndividual = new FragmentIndividual();
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction fmt = fm.beginTransaction();
intent1 = new Intent(getApplicationContext(), MainActivity.class);
intent1.putExtra("name", "nnnaa");
Bundle bundle = new Bundle();
bundle.putString("name", mAuth.getCurrentUser().getDisplayName());
bundle.putString("email", mAuth.getCurrentUser().getEmail());
bundle.putString("phone", mAuth.getCurrentUser().getPhoneNumber());
System.out.println(email);
System.out.println(mAuth.getCurrentUser().getEmail());
startActivity(intent1);
} else {
if(task.getException() != null){
startToast(task.getException().toString());
}
}
}
});
}else{
startToast("빈 칸을 채워주세요");
}
}
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_individual, container, false);
Bundle bundle = this.getArguments();
if(bundle != null){
bundle = getArguments();
String name = bundle.getString("name");
String email = bundle.getString("email");
String phone = bundle.getString("phone");
View v = inflater.inflate(R.layout.fragment_individual, container, false);
nameTv = (TextView)v.findViewById(R.id.nameTv);
emailTv = (TextView)v.findViewById(R.id.emailTv);
phoneTv = (TextView)v.findViewById(R.id.phoneTv);
nameTv.setText(name);
emailTv.setText(email);
phoneTv.setText(phone);
}
return view;
}