1

I'm trying to tweet an image on twitter from the SD card. Also tried to tweet from image URL, but the image not showing on composer.

Below is my code:

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
    File destination = new File(Environment.getExternalStorageDirectory(),
            System.currentTimeMillis() + ".jpg");
    FileOutputStream fo;
    try {
        destination.createNewFile();
        fo = new FileOutputStream(destination);
        fo.write(bytes.toByteArray());
        fo.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    String path = destination.getPath();
    Uri bmpUri = Uri.parse("file://" + destination.getAbsolutePath());
    //Uri bmpUri = Uri.parse(path);


    String body = "…Check it out for yourself !";
    TweetComposer.Builder builder = new TweetComposer.Builder(this)
            .text(body)
            .image(bmpUri);

    builder.show();

I have gone through available solutions but none of them helped. Please help me to know why an image is not tweeting.

Any help will be much appreciated.Thanks in advance.

pfx
  • 20,323
  • 43
  • 37
  • 57
Pragya Singla
  • 244
  • 3
  • 13

0 Answers0