解析文件保存错误,“”无法编码未保存的parsefile“
我在Parse上传图片时遇到错误。请帮我解决这个问题。 我尝试了一些Stack溢出问题,但没什么,所以请帮助我,提前谢谢。
当我按提交按钮,然后我收到以下错误。
错误是
java.lag.illegalStateException: Unable to encode an unsaved parsefile
我的代码是
bitmapLogo=BitmapFactory.decodeFile(picturePath); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmapLogo.compress(Bitmap.CompressFormat.PNG,0, stream); byte[] image = stream.toByteArray(); String filename=etUser.getText().toString()+".png"; ParseFile file = new ParseFile(filename, image); System.out.println("PARSE FILE NAME : "+picturePath); file.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if(e!=null){ btSignup.setText(e.getMessage()); } } },new ProgressCallback() { @Override public void done(Integer integer) { btSignup.setText(""+integer); } }); String spin= String.valueOf(spinBCat.getSelectedItem()); ParseUser user = new ParseUser(); user.setUsername(etUser.getText().toString()); user.setPassword(etPass.getText().toString()); user.setEmail(etEmail.getText().toString()); user.put("logoname",etUser.getText().toString()); user.put("blogo",file); user.signUpInBackground(new SignUpCallback() { public void done(ParseException e) { if (e == null) { Toast.makeText(AddBusinessActivity.this,"You are Successfully Signed Up",Toast.LENGTH_LONG).show(); signUpSucess(); } else { Toast.makeText(AddBusinessActivity.this,""+e.getMessage(),Toast.LENGTH_LONG).show(); // Sign up didn't succeed. Look at the ParseException // to figure out what went wrong } } });
最后我解决了这个问题。 只需在ProgressCallback
方法中添加代码即可
代码是
bitmapLogo=BitmapFactory.decodeFile(picturePath); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmapLogo.compress(Bitmap.CompressFormat.PNG,0, stream); byte[] image = stream.toByteArray(); String filename=etUser.getText().toString()+".png"; ParseFile file = new ParseFile(filename, image); System.out.println("PARSE FILE NAME : "+picturePath); file.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if(e!=null){ btSignup.setText(e.getMessage()); } } },new ProgressCallback() { @Override public void done(Integer integer) { String spin= String.valueOf(spinBCat.getSelectedItem()); ParseUser user = new ParseUser(); user.setUsername(etUser.getText().toString()); user.setPassword(etPass.getText().toString()); user.setEmail(etEmail.getText().toString()); user.put("logoname",etUser.getText().toString()); user.put("blogo",file); user.signUpInBackground(new SignUpCallback() { public void done(ParseException e) { if (e == null) { Toast.makeText(AddBusinessActivity.this,"You are Successfully Signed Up",Toast.LENGTH_LONG).show(); signUpSucess(); } else { Toast.makeText(AddBusinessActivity.this,""+e.getMessage(),Toast.LENGTH_LONG).show(); // Sign up didn't succeed. Look at the ParseException // to figure out what went wrong } } }); } });
- 通过套接字编程将png图像文件从服务器(桌面)发送到客户端(android)
- Android:TimeStamp转换问题!
- NameValuePair,HttpParams,HttpConnection Params在登录app的服务器请求类上已弃用
- Android mupdf java.lang.UnsatisfiedLinkError:dlopen失败:找不到符号“atof”
- 我无法在Parse的应用程序中收到推送通知
- 如何使用简单的String(字符串格式的xml)调用SOAP Web服务
- Java(Eclipse) – 条件编译
- ArrayAdapter.remove 的UnsupportedOperationException
- 解析Android中的JSON问题