Reputation: 900
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();
}
}
});
}
Upvotes: 1
Views: 1422
Reputation: 782
You are just forgetting to save your User object: ParseUser.getCurrentUser().saveEventually();
Upvotes: 1