Created
April 26, 2021 09:53
-
-
Save nuriyevn/618336c5f17c4c24d8d5da90b8302e0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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