我想用parse.com用户注册,我首先尝试使用parsefile(profilePicture)注册,但我得到了异常“java.lag.illegalStateException:无法使用此代码编码未保存的parsefile”,
final ParseUser UserObject = new ParseUser();
UserObject.setUsername(userModel.getUsername());
UserObject.setEmail(userModel.getEmail());
UserObject.setPassword(userModel.getPassword());
UserObject.put("Mobile_Number",userModel.getMobile_Number());
UserObject.put("Name",userModel.getName());
if(Mem_photobitmap!=null){
UserObject.put("ProfilePicture",profilepicFile);
}
UserObject.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException ex) {
// TODO Auto-generated method stub
dismissProgressdialog();
if (ex == null) {
application.saveUser_UserName(userModel.getUsername());
application.saveUser_Name(userModel.getName());
application.savePassword(userModel.getPassword());
application.saveUserEmail(userModel.getEmail());
Toast.makeText(getApplicationContext(), "Signed Up Successfully", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
});
我搜索并获得了链接Parse file saveing error,""Unable to encode an unsaved parsefile"
我再次尝试了这段代码,首先上传了profilepicture,然后使用ProgressCallback()我尝试注册,但是这个代码也得到了相同的异常
//first save profile pic to parse
if(Mem_photobitmap !=null){
profilepicFile = userModel.getProfilePicture();
profilepicFile.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if(e!=null){
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}, new ProgressCallback() {
@Override
public void done(Integer arg0) {
// TODO Auto-generated method stub
// PrepareParseUser();
final ParseUser UserObject = new ParseUser();
UserObject.setUsername(userModel.getUsername());
UserObject.setEmail(userModel.getEmail());
UserObject.setPassword(userModel.getPassword());
UserObject.put("Mobile_Number",userModel.getMobile_Number());
UserObject.put("Name",userModel.getName());
if(Mem_photobitmap!=null){
UserObject.put("ProfilePicture",profilepicFile);
}
UserObject.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException ex) {
// TODO Auto-generated method stub
dismissProgressdialog();
if (ex == null) {
application.saveUser_UserName(userModel.getUsername());
application.saveUser_Name(userModel.getName());
application.savePassword(userModel.getPassword());
application.saveUserEmail(userModel.getEmail());
Toast.makeText(getApplicationContext(), "Signed Up Successfully", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
});
}
});
任何帮助,请
答案 0 :(得分:0)
我得到了答案 我在没有个人资料图片的情况下注册了parse.com,然后用完简档图片更新了用户
showProgressdialog();
final ParseUser UserObject = new ParseUser();
UserObject.setUsername(userModel.getUsername());
UserObject.setEmail(userModel.getEmail());
UserObject.setPassword(userModel.getPassword());
UserObject.put("Mobile_Number",userModel.getMobile_Number());
UserObject.put("Name",userModel.getName());
UserObject.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException ex) {
// TODO Auto-generated method stub
if (ex == null) {
if(Mem_photobitmap!=null){
application.saveUser_UserName(userModel.getUsername());
application.saveUser_Name(userModel.getName());
application.savePassword(userModel.getPassword());
application.saveUserEmail(userModel.getEmail());
UserObject.put("ProfilePicture", userModel.getProfilePicture());
UserObject.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException ex) {
// TODO Auto-generated method stub
dismissProgressdialog();
if (ex == null) {
Toast.makeText(getApplicationContext(), "Signed Up Successfully", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
});
}else{
dismissProgressdialog();
Toast.makeText(getApplicationContext(), "Signed Up Successfully", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
dismissProgressdialog();
}
}
});