gpt4 book ai didi

android - Parse.com 文件保存 Android 不工作

转载 作者:行者123 更新时间:2023-11-30 03:03:32 25 4
gpt4 key购买 nike

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

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

关于android - Parse.com 文件保存 Android 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22186388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com