I'm trying to share an image on twitter from the application drawable resources. I've also tried supplying a URL for the image on my server, but the result was the same.
Please note that when the tweetcomposer is open, it does show the image, but when I click the tweet button an error is displayed in the logcat. The documentations states:
The image Uri should be a Uri using the content:// scheme.
https://dev.twitter.com/twitterkit/android/compose-tweets
What do I need to change in the code in order to get this done?
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/drawable/some_image");
final Intent intent = new ComposerActivity.Builder(MainActivity.this)
.session(session)
.image(uri)
.text("This is atest!")
.hashtags("#testest")
.createIntent();
startActivity(intent);
The tweet failed with this message:
Post Tweet failed
com.twitter.sdk.android.core.TwitterException: Uri file path resolved to null at com.twitter.sdk.android.tweetcomposer.TweetUploadService.uploadMedia(TweetUploadService.java:125) at com.twitter.sdk.android.tweetcomposer.TweetUploadService.uploadTweet(TweetUploadService.java:84) at com.twitter.sdk.android.tweetcomposer.TweetUploadService.onHandleIntent(TweetUploadService.java:79) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:68) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.os.HandlerThread.run(HandlerThread.java:61)