0

I am using Fabric in my Android app to compose tweets and I need to include an image. The TweetComposer.Builder class has an image() method that takes a Uri object. I am trying to use an image that exists in the assets directory of my app, but I keep getting an error couldn't load the image.

here is my code:

File myImageFile = new File("file:///android_asset/image/test_icon.png");
Uri myImageUri = Uri.fromFile(myImageFile);

TweetComposer.Builder builder = new TweetComposer.Builder(this)
     .text("test")
     .image(myImageUri);

builder.show();

In the debugger I have confirmed that the Uri was successfully created, yet it still fails to load the image. Any ideas?

2

You have to put image in SDcards because .image(URI uri) method just pass url to offical app of Twitter and Twitter app find image in SDcard by using provided url.

  • You're right, had to copy the image from assets to externalStorageDirectory (Don't forget to add the permission!!). What a PITA. Thanks Sunil! – d370urn3ur Aug 19 '15 at 10:15
  • wot if SDCards are not there in mobile!!!! – user3013257 Nov 6 '15 at 14:50
  • It should be in external memory. Fabric can't access image from app. – Sunil Jan 1 '17 at 14:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.