我试图在android中发送直接消息时附加图像文件或位图。 请帮忙。
答案 0 :(得分:0)
请参阅此处的链接... https://stackoverflow.com/a/12740436/3884250
/** * To upload a picture with some piece of text.
* * * @param file The file which we want to share with our tweet
* @param message Message to display with picture
* @param twitter Instance of authorized Twitter class
* @throws Exception exception if any
*/ public void uploadPic(File file, String message,Twitter twitter) throws Exception
{
try{
StatusUpdate status = new StatusUpdate(message);
status.setMedia(file);
twitter.updateStatus(status);
} catch(TwitterException e){
Log.d("TAG", "Pic Upload error" + e.getErrorMessage()); throw e;
}
}