Parse.com文件保存Android无法正常工作 [英] Parse.com File saving Android not working

查看:111
本文介绍了Parse.com文件保存Android无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mealspotting教程之后对我的代码进行了建模,但出于某种原因,我无法在数据浏览器中看到保存的文件。这是为什么?这是我的代码:

I modeled my code after their Mealspotting tutorial but for some reason, I can't see the file saved in the Data Browser. Why is that? Here is my code:

private void saveScaledPhoto(byte[] data) {

        // Resize photo from camera byte array
        Bitmap snypImage = BitmapFactory.decodeByteArray(data, 0, data.length);
        Bitmap snypImageScaled = Bitmap.createScaledBitmap(snypImage, 200, 200
                * snypImage.getHeight() / snypImage.getWidth(), false);

        // Override Android default landscape orientation and save portrait
        Matrix matrix = new Matrix();
        matrix.postRotate(90);
        Bitmap rotatedScaledMealImage = Bitmap.createBitmap(snypImageScaled, 0,
                0, snypImageScaled.getWidth(), snypImageScaled.getHeight(),
                matrix, true);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        rotatedScaledMealImage.compress(Bitmap.CompressFormat.JPEG, 100, bos);

        byte[] scaledData = bos.toByteArray();

        // Save the scaled image to Parse
        photoFile = new ParseFile("snyp.jpg", scaledData);
        photoFile.saveInBackground(new SaveCallback() {

            public void done(ParseException e) {
                if (e == null) {
                    ParseUser.getCurrentUser().put("photo",photoFile);
                    Log.d("save status",photoFile.getName() + " is saved!");
                } else {

                    Toast.makeText(getActivity(),
                            "Error saving: " + e.getMessage(),
                            Toast.LENGTH_LONG).show();
                }
            }
        });
    }


推荐答案

你只是忘记保存您的用户对象: ParseUser.getCurrentUser()。saveEventually();

You are just forgetting to save your User object: ParseUser.getCurrentUser().saveEventually();

这篇关于Parse.com文件保存Android无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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