After fabric removal , now Twitter kit 3 is used in the android
Case :
I need share the text , image and video without opening the Twitter Composer
I am sharing the text , image and the video using twitter kit 3 by using the method StatusesService
So i can share the text by using below code :
final TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
StatusesService statusesService = TwitterCore.getInstance().getApiClient(session).getStatusesService();
statusesService.update("Click this link "+getShareLink(),null,null,null,null,null,null,null,null).enqueue(new Callback<Tweet>() {
@Override
public void success(Result<Tweet> result) {
Toast.makeText(context,"Tweet success ",Toast.LENGTH_SHORT).show();
Log.e(TAG,"Twitter "+ result.data.toString());
}
@Override
public void failure(TwitterException exception) {
Toast.makeText(context,"Tweet failure ",Toast.LENGTH_SHORT).show();
Log.e(TAG,"Twitter "+ exception.getMessage());
}
});
For image upload we can use MediaService
and for uploading it we can use MediaService.upload()
method , but in the MediaService
they are only prompt the images to upload and i also checked their docs .
And now How to share Video in the Twitter kit 3 using StatuesServices
or any other method ?
1) The native video upload support is only available with iOS (See attachment section)
2) Quick Bad workaround You can convert video to gif and upload it.
3) Proper solution:
You can extend the kit, and use the media/uploads endpoint.
See this to make a post request.