0
我正在創建用戶註冊與解析的應用程序。當我填寫編輯字段,按註冊按鈕敬酒的消息顯示,無效的令牌session.I填寫所有filed.How我可以解決這個下面是problem.Here我的代碼在Android中的有效會話令牌與解析
package com.example.home.communicate
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
public class SignupActivity extends AppCompatActivity {
EditText editusername, editpassword, editemail, editrepassword;
Button signup;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
editusername = (EditText) findViewById(R.id.usernamesignup);
editemail = (EditText) findViewById(R.id.email);
editpassword = (EditText) findViewById(R.id.passwordinsignup);
editrepassword = (EditText) findViewById(R.id.re_enterpassword);
signup = (Button) findViewById(R.id.signup);
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
userSignUp();
}
});
}
private void userSignUp() {
String username = editusername.getText().toString().trim();
String email = editemail.getText().toString().trim();
String password = editpassword.getText().toString().trim();
String repassword = editrepassword.getText().toString().trim();
boolean validationError = false;
StringBuilder validationErrorMessage = new StringBuilder(getString(R.string.error_intro));
if (username.length() == 0) {
validationError = true;
validationErrorMessage.append(getString(R.string.error_blank_username));
}
if (password.length()== 0){
if(validationError){
validationErrorMessage.append(getString(R.string.error_join));
}
validationError = true;
validationErrorMessage.append(getString(R.string.error_blank_password));
}
if(!password.equals(repassword)){
if(validationError){
validationErrorMessage.append(getString(R.string.error_join));
}
validationError = true;
validationErrorMessage.append(getString(R.string.error_mismatched_passwords));
}
if (email.length()== 0){
if(validationError){
validationErrorMessage.append(getString(R.string.error_join));
}
validationError = true;
validationErrorMessage.append(getString(R.string.error_blank_email));
}
if(validationError){
Toast.makeText(SignupActivity.this, validationErrorMessage.toString(),Toast.LENGTH_SHORT).show();
}
ParseUser user = new ParseUser();
user.setUsername(username);
user.setEmail(email);
user.setPassword(password);
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
if (e==null){
Intent intent = new Intent(SignupActivity.this,MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
else {
Toast.makeText(SignupActivity.this,e.getMessage(),Toast.LENGTH_LONG).show();
}
}
});
}
}