There is an issue with scale function in yours ImageUtils class.
If URI points to the resource at the web this function just crashed. I think that's because of this line of code:
InputStream is = context.getContentResolver().openInputStream(photoUri);
My application posts to Facebook and Twitter from the external resource were links are alive just for 24 hours, so I can't just use the link added to the message. And I prefer not to save every image on the user's phone. So I wrote this code snippet:
Bitmap imgBitmap = ImageUtils.getBitmapFromURL(pictureURL);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imgBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] data = baos.toByteArray();
tweet.setImageData(data);
I know it does not change the ratio of the photo, but your method of finding it out is pretty bad for my situation with external image resource (I can't make user to download photo twice because they could be huge).
There is an issue with scale function in yours ImageUtils class. If URI points to the resource at the web this function just crashed. I think that's because of this line of code:
My application posts to Facebook and Twitter from the external resource were links are alive just for 24 hours, so I can't just use the link added to the message. And I prefer not to save every image on the user's phone. So I wrote this code snippet:
And then I'm using it this way:
I know it does not change the ratio of the photo, but your method of finding it out is pretty bad for my situation with external image resource (I can't make user to download photo twice because they could be huge).
Hope this helps.