To complete Register should be three steps in different classes and method read all string from another activities . When starting project i have some error!
class1 (RegisterActivity.java)
public class RegisterActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
Next = (Button)findViewById(R.id.next);
Fname = (EditText)findViewById(R.id.fname);
Lname = (EditText)findViewById(R.id.lname);
Next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fname = Fname.getText().toString().trim();
lname = Lname.getText().toString().trim();
Intent intent = new Intent(RegisterActivity.this,RegisterStepTwoActivity.class);
startActivity(intent);
finish();
}
});
}
}
class2 (RegisterStepTwoActivity)
public class RegisterStepTwoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register_step_two);
overridePendingTransition(R.anim.animation,R.anim.animation2);
Day = (Spinner)findViewById(R.id.spinner_dates);
Month = (Spinner)findViewById(R.id.spinner_months);
Year = (Spinner)findViewById(R.id.spinner_years);
Male = (RadioButton) findViewById(R.id.male);
Female = (RadioButton) findViewById(R.id.female);
RG = (RadioGroup)findViewById(R.id.rg);
Next = (Button)findViewById(R.id.next_s_two);
Next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
day = Day.getSelectedItem().toString().trim();
month = Month.getSelectedItem().toString().trim();
year = Year.getSelectedItem().toString().trim();
int id = RG.getCheckedRadioButtonId();
Male = (RadioButton)findViewById(id);
Female = (RadioButton)findViewById(id);
gender = ((RadioButton) findViewById(id)).getText().toString().trim();
Male.getText();
Female.getText();
Intent intent = new Intent(RegisterStepTwoActivity.this,RegisterStepThreeActivity.class);
startActivity(intent);
finish();
}
});
}
}
Here , i want to call all there class3 (RegisterStepThreeActivity)
public class RegisterStepThreeActivity extends AppCompatActivity {
EditText E_mail , Password;
Button Complete;
String email , password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register_step_three);
overridePendingTransition(R.anim.animation,R.anim.animation2);
Complete = (Button) findViewById(R.id.complete);
E_mail = (EditText) findViewById(R.id.email);
Password = (EditText) findViewById(R.id.password);
Complete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
email = E_mail.getText().toString().trim();
password = Password.getText().toString().trim();
RegisterActivity reg = new RegisterActivity();
RegisterStepTwoActivity regtwo = new RegisterStepTwoActivity();
if (!regtwo.day.isEmpty() && !regtwo.month.isEmpty() && !regtwo.year.isEmpty() && !regtwo.gender.isEmpty() &&
!reg.fname.equals(reg.Fname) && !reg.lname.isEmpty() && !email.isEmpty() && !password.isEmpty()) {
registerUser(reg.fname, reg.lname, regtwo.day, regtwo.month, regtwo.year, regtwo.gender, email, password);
}
else {
Snackbar.make(v, "Please enter your datalist", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
}
});
}
method registerUser can't applied all String! Error :
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference