我模仿我的代碼,他們Mealspotting教程後,但由於某些原因,我無法看到保存在數據瀏覽器中的文件。這是爲什麼?這裏是我的代碼:Parse.com文件保存的Android不工作
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();
}
}
});
}
這不是在文件存儲或者 – shreyashirday
你是如何保存圖像文件?你能發佈代碼嗎? – yushulx
「 ParseUser.getCurrentUser()把(」照片」,photoFile); – shreyashirday