我的目标是获取用户选择的图片并使用它填充图像视图.然后,在单击按钮时,该图像将被发送到Parse数据库.我知道我必须将imageview转换为字节数组,但似乎不起作用.
任何帮助将受到高度赞赏.
这是我的代码:
//send the imageviwew to parse database
public void sendToParseBtn (View view){
Bitmap bitmapImage = findViewById (R.id.imageView);
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(bitmapImage);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmapImage.compress(Bitmap.CompressFormat.JPEG, 40, stream);
byte[] byteArray = stream.toByteArray();
ParseFile file = new ParseFile("an.jpg",byteArray);
ParseObject object = new ParseObject("MyParseObject");
object.put("imageFile", file);
object.saveInBackground();
}