Skip to content

Instantly share code, notes, and snippets.

@nuriyevn
Created April 26, 2021 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuriyevn/618336c5f17c4c24d8d5da90b8302e0b to your computer and use it in GitHub Desktop.
Save nuriyevn/618336c5f17c4c24d8d5da90b8302e0b to your computer and use it in GitHub Desktop.
ImageView pictureId = (ImageView)findViewById(R.id.pictureId);
BitmapDrawable drawableforimage = (BitmapDrawable) pictureId.getDrawable();
Bitmap bitmap = drawableforimage.getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,100,stream);
byte[] byteArray = stream.toByteArray();
ParseFile file = new ParseFile("grapefruit.jpg",byteArray);
ParseObject object = new ParseObject("Image");
object.put("image",file);
object.put("creator", "coffeeshots");
object.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if(e == null){
Toast.makeText(MainActivity.this,"Image has been shared",Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(MainActivity.this,"Issue uploading image",Toast.LENGTH_SHORT).show();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment