2014-12-24 41 views
1

我用了Vcard嫌對於GET頭像圖片,但它退還給我形象化身尺寸32 * 32如何獲得高質量的圖像化身嫌XMPP的Facebook

它小的圖像,所以我想獲得高品質,如Facebook做或其他應用程序做

有人可以幫助我嗎?

我嘗試在Gooogle企業搜索,但幾乎線程的使用電子名片爲獲取化身說

我使用的方法下面的GET頭像與維卡

=>我的解決辦法是使用圖形API從Facebook:

String urlAvatar = "https://graph.facebook.com/" + StringUtils.parseName(childrenEntryItems.getJid()). 
replace("-", "") + "/picture?type=normal"; 

public static byte[] getAvatarByteArray(XMPPConnection xmppConnection, String user) { 
 
\t \t VCard vCard = new VCard(); 
 
\t \t SmackConfiguration.setPacketReplyTimeout(30000); 
 
// \t \t ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", 
 
// \t \t \t \t new VCardProvider()); 
 
\t \t try { 
 
\t \t \t vCard.load(xmppConnection, user); 
 
\t \t } catch (XMPPException e1) { 
 
\t \t \t // TODO Auto-generated catch block 
 
\t \t \t e1.printStackTrace(); 
 
\t \t } 
 
// \t \t Log.d("Giang", vCard.toXML() + " byte length = " 
 
// \t \t \t \t + vCard.getAvatar().length); // complete VCard information 
 

 
\t \t return vCard.getAvatar(); 
 
\t } 
 
\t 
 
\t public static Bitmap makeBitemap(byte[] value) { 
 
\t \t if (value == null) 
 
\t \t \t return null; 
 

 
\t \t // Load only size values 
 
\t \t BitmapFactory.Options sizeOptions = new BitmapFactory.Options(); 
 
\t \t sizeOptions.inJustDecodeBounds = true; 
 
\t \t BitmapFactory.decodeByteArray(value, 0, value.length, sizeOptions); 
 

 
\t \t // Calculate factor to down scale image 
 
\t \t int scale = 1; 
 
\t \t int width_tmp = sizeOptions.outWidth; 
 
\t \t int height_tmp = sizeOptions.outHeight; 
 
\t \t while (width_tmp/2 >= 256 && height_tmp/2 >= 256) { 
 
\t \t \t scale *= 2; 
 
\t \t \t width_tmp /= 2; 
 
\t \t \t height_tmp /= 2; 
 
\t \t } 
 

 
\t \t // Load image 
 
\t \t BitmapFactory.Options resultOptions = new BitmapFactory.Options(); 
 
\t \t resultOptions.inSampleSize = scale; 
 
\t \t return BitmapFactory.decodeByteArray(value, 0, value.length, 
 
\t \t \t \t resultOptions); 
 
\t }

回答

0

我認爲最好的交易是將avatar的URL存儲在其中一個自定義v-cards中,並使用一些圖像加載庫通過HTTP獲取它。請記住,xmpp是一個基於流的體系結構,我會謹慎地通過發送大文件來阻止流。

+0

我發現另一個解決方案是使用來自Facebook的Graphic api,我更新了我的問題,謝謝 – nguyenvangiangbn