I'm an Android student and I'm trying to set up a Sign Up screen and save the user in parse.com but when I click on Sign Up button gives me error and I don't know why. Also I don't know how to test if the password and repeat password editable texts are the same.
public void onCreate (Bundle saveInstanceState) {
super.onCreate(saveInstanceState);
setContentView(R.layout.signupscreen);
Button signup = (Button) findViewById(R.id.signup);
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String username = String.valueOf(findViewById(R.id.username_edittext));
String password = String.valueOf(findViewById(R.id.password_edittext));
String repassword = String.valueOf(findViewById(R.id.repassword_edittext));
String email = String.valueOf(findViewById(R.id.email_edittext));
String universitat = String.valueOf(findViewById(R.id.universitat_edittext));
String carrera = String.valueOf(findViewById(R.id.carrera_edittext));
// Force user to fill up the form
if (username.equals("") && password.equals("")) {
Toast.makeText(getApplicationContext(),
"Please complete the sign up form",
Toast.LENGTH_LONG).show();
} else {
// Save new user data into Parse.com Data Storage
ParseUser user = new ParseUser();
user.setUsername(username);
user.setPassword(password);
user.setEmail(email);
// Introduir universitat i carrera d'una llista de la DB sincronitzada amb Parse
//user.put("carrera", carrera);
//user.put("universitat", universitat);
Log.v("username: ", username);
Log.v("password: ", password);
Log.v("email: ", email);
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(com.parse.ParseException e) {
if (e == null) {
// Show a simple Toast message upon successful registration
Toast.makeText(getApplicationContext(),
"Successfully Signed up, please log in.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),
"Sign up Error", Toast.LENGTH_LONG)
.show();
}
}
});
}
}
});
}
Error message:
06-09 22:23:52.764 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfofornet+,hn 13(0x6170692e706172),sn(),hints(known),family 0,flags 4
06-09 22:23:52.764 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfofornet-, err=8
06-09 22:23:52.764 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfofornet+,hn 13(0x6170692e706172),sn(),hints(known),family 0,flags 1024
06-09 22:23:52.764 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfofornet-, pass to proxy
06-09 22:23:52.774 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfo_proxy+
06-09 22:23:52.774 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfo_proxy get netid:0
06-09 22:23:52.814 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfo_proxy-, success
06-09 22:23:52.824 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfofornet+,hn 13(0x35342e38382e31),sn(),hints(known),family 0,flags 4
06-09 22:23:52.824 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfofornet-, SUCCESS
06-09 22:23:53.324 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfofornet+,hn 13(0x6170692e706172),sn(),hints(known),family 0,flags 4
06-09 22:23:53.324 5833-6759/com.example.aleix.selenotesapp D/libc﹕ [NET] android_getaddrinfofornet-, err=8
As I mentioned above, usually you would use something like
findViewById(R.id.username_edittext).getText().toString()
to get an EditText
's value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.