首页 新闻 会员 周边

smack+openfire android开发聊天 获取好友头像问题

1
悬赏园豆:10 [待解决问题]
  1. 有哪位大神帮我讲解一下!!!下列的代码。不胜感激
  2. /** 
  3.      * 修改用户头像 
  4.      *  
  5.      * @param connection 
  6.      * @param f 
  7.      * @throws XMPPException 
  8.      * @throws IOException 
  9.      */  
  10.     public static void changeImage(XMPPConnection connection, File f)  
  11.             throws XMPPException, IOException {  
  12.   
  13.         VCard vcard = new VCard();  
  14.         vcard.load(connection);  
  15.   
  16.         byte[] bytes;  
  17.   
  18.         bytes = getFileBytes(f);  
  19.         String encodedImage = StringUtils.encodeBase64(bytes);  
  20.         vcard.setAvatar(bytes, encodedImage);  
  21.         vcard.setEncodedImage(encodedImage);  
  22.         vcard.setField("PHOTO""<TYPE>image/jpg</TYPE><BINVAL>" + encodedImage  
  23.                 + "</BINVAL>"true);  
  24.   
  25.         ByteArrayInputStream bais = new ByteArrayInputStream(vcard.getAvatar());  
  26.         FormatTools.getInstance().InputStream2Bitmap(bais);  
  27.   
  28.         vcard.save(connection);  
  29.     }  
火星上的小毛驴的主页 火星上的小毛驴 | 初学一级 | 园豆:192
提问于:2016-11-04 11:25
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册