可以使用twitter4j将图像附加到直接消息中吗?

时间:2014-07-01 12:15:13

标签: android twitter twitter4j

我试图在android中发送直接消息时附加图像文件或位图。 请帮忙。

1 个答案:

答案 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; 
     }
  }