在Twitter上分享来自drawable或web url的图片

时间:2017-12-18 15:57:18

标签: android twitter

我试图通过应用程序可绘制资源在twitter上分享图像。我也尝试在服务器上提供图像的URL,但结果是一样的。

请注意,当tweetcomposer打开时,它会显示图像,但是当我点击推文按钮时,logcat中会显示错误。 文件说明:

  

图像Uri应该是使用content:// scheme的Uri。

https://dev.twitter.com/twitterkit/android/compose-tweets

为了完成这项工作,我需要更改代码?

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);

推文失败时收到此消息:

  

发布推文失败

     
    

com.twitter.sdk.android.core.TwitterException:Uri文件路径已解析为null                                                                                       在com.twitter.sdk.android.tweetcomposer.TweetUploadService.uploadMedia(TweetUploadService.java:125)                                                                                       在com.twitter.sdk.android.tweetcomposer.TweetUploadService.uploadTweet(TweetUploadService.java:84)                                                                                       在com.twitter.sdk.android.tweetcomposer.TweetUploadService.onHandleIntent(TweetUploadService.java:79)                                                                                       在android.app.IntentService $ ServiceHandler.handleMessage(IntentService.java:68)                                                                                       在android.os.Handler.dispatchMessage(Handler.java:102)                                                                                       在android.os.Looper.loop(Looper.java:154)                                                                                       在android.os.HandlerThread.run(HandlerThread.java:61)

  

0 个答案:

没有答案