解析文件saveing​​错误,""无法连接code未保存parsefile" [英] Parse file saveing error,""Unable to encode an unsaved parsefile"

查看:408
本文介绍了解析文件saveing​​错误,""无法连接code未保存parsefile"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误,同时对上传图像Parse.Please帮我这件事。我尝试了一些堆栈溢出的问题,但它的什么都没有,所以,请大家帮帮我,提前感谢。

当我preSS提交按钮,然后我收到以下错误。

误差

无法连接code未保存parsefile:

  java.lag.illegalStateException

和我的code是

  bitmapLogo = BitmapFactory.de codeFILE(picturePath);
    ByteArrayOutputStream流=新ByteArrayOutputStream();
    bitmapLogo.com preSS(Bitmap.Com pressFormat.PNG,0,流);
    字节[] =图像stream.toByteArray();
    。字符串文件名= etUser.getText()的toString()+PNG;
    ParseFile文件=新ParseFile(文件名,图像);    的System.out.println(分析文件名:+ picturePath);
    file.saveInBackground(新SaveCallback(){
        @覆盖
        公共无效完成(ParseException的E){
            如果(E!= NULL){
                btSignup.setText(e.getMessage());
            }
        }
    },新ProgressCallback(){
        @覆盖
        公共无效完成(整数整数){
            btSignup.setText(+整数);
        }
    });    串自旋=将String.valueOf(spinBCat.getSelectedItem());
    ParseUser用户=新ParseUser();
    user.setUsername(etUser.getText()的toString());
    user.setPassword(etPass.getText()的toString());
    user.setEmail(etEmail.getText()的toString());
    user.put(徽标名称,etUser.getText()的toString());
    user.put(blogo文件);    user.signUpInBackground(新SignUpCallback(){        公共无效完成(ParseException的E){
            如果(E == NULL){
                Toast.makeText(AddBusinessActivity.this,你已成功注册了Toast.LENGTH_LONG).show();
                    signUpSucess();            }其他{
                Toast.makeText(AddBusinessActivity.this,+ e.getMessage(),Toast.LENGTH_LONG).show();
                //注册没有成功。看ParseException的
                //找出什么地方出了错
            }
        }
    });


解决方案

最后我解决这个问题的答案。只需添加code在 ProgressCallback

code是

  bitmapLogo = BitmapFactory.de codeFILE(picturePath);
ByteArrayOutputStream流=新ByteArrayOutputStream();
bitmapLogo.com preSS(Bitmap.Com pressFormat.PNG,0,流);
字节[] =图像stream.toByteArray();
。字符串文件名= etUser.getText()的toString()+PNG;
ParseFile文件=新ParseFile(文件名,图像);的System.out.println(分析文件名:+ picturePath);
file.saveInBackground(新SaveCallback(){
    @覆盖
    公共无效完成(ParseException的E){
        如果(E!= NULL){
            btSignup.setText(e.getMessage());
        }
    }
},新ProgressCallback(){
    @覆盖
    公共无效完成(整数整数){
            串自旋=将String.valueOf(spinBCat.getSelectedItem());
ParseUser用户=新ParseUser();
user.setUsername(etUser.getText()的toString());
user.setPassword(etPass.getText()的toString());
user.setEmail(etEmail.getText()的toString());
user.put(徽标名称,etUser.getText()的toString());
user.put(blogo文件);user.signUpInBackground(新SignUpCallback(){    公共无效完成(ParseException的E){
        如果(E == NULL){
            Toast.makeText(AddBusinessActivity.this,你已成功注册了Toast.LENGTH_LONG).show();
                signUpSucess();        }其他{
            Toast.makeText(AddBusinessActivity.this,+ e.getMessage(),Toast.LENGTH_LONG).show();
            //注册没有成功。看ParseException的
            //找出什么地方出了错
        }
    }
});
    }
});

I am getting error while uploading image on Parse.Please Help me about this. I tried some Stack overflow question but its nothing, So please help me,Thank in advance.

When i press Submit button then i am getting following error.

error is

java.lag.illegalStateException: Unable to encode an unsaved parsefile

and my code is

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
            }
        }
    });

解决方案

Finally I solve this answer. Just add code in ProgressCallback method

Code is

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
        }
    }
});
    }
});

这篇关于解析文件saveing​​错误,""无法连接code未保存parsefile"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆