@bonnell thank you ,what i want to do is share in the background with image and text when i have signed in twitter ,maybe you have another way to complete this function? in my mind, i find interface StatusesService ,first i upload one image ,after i get midiaIdString,execute the method above ,here my code:
TwitterApiClient apiClient = TwitterCore.getInstance().getApiClient(session);
MediaService mediaService = apiClient.getMediaService();
final com.twitter.sdk.android.core.services.StatusesService service = apiClient.getStatusesService();
Log.e(TAG, “service” + service);
//上传图片
byte[] byte_content = mByteContent;
byte[] byte_content_base64 = mByte64Content;
RequestBody media = RequestBody.create(null, byte_content);
RequestBody mediaData = RequestBody.create(null, byte_content_base64);
Call<Media> upload = mediaService.upload(media, mediaData, null);
upload.enqueue(new Callback<Media>() {
@Override
public void success(Result<Media> result) {
mediaIdString = result.data.mediaIdString;
Call<Tweet> update = service.update("test", null, null, null, null, null, null, null, mediaIdString);
update.enqueue(new Callback<Tweet>() {
@Override
public void success(Result<Tweet> result) {
Log.e(TAG, "Result<Tweet> result" + result.data.toString());
}
@Override
public void failure(TwitterException exception) {
Log.e(TAG, "Result<Tweet> result" + exception.getMessage());
}
});
}
@Override
public void failure(TwitterException exception) {
Log.e(TAG, "Result<Media> result" + exception.getMessage());
}
});