【发布时间】:2014-02-21 09:51:17
【问题描述】:
让我解释一下我的问题。
我正在尝试在应用 Imageview 中设置 Facebook 个人资料图片,类似这样的东西 ..
// Getting Facebook URL image and converting same to bitmap
Bitmap mIcon1;
URL img_value = new URL("http://graph.facebook.com/"+ userProfileID +"/picture?type=square");
BitmapFactory.Options options = new BitmapFactory.Options();
mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream(), null, options);
然后在..
// I am setting bitmap to imageview .. some thing like ..
if(mIcon1!=null) {
user_picture.setImageBitmap(mIcon1);
}
到这里为止,它工作得很好......
现在我需要将该 Facebook 个人资料图片保存到位于服务器的数据库中...
我正在表演类似的东西..
// Created a method for encoding ..
public static String encodeTobase64(Bitmap image)
{
Bitmap immagex=image;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT);
Log.e("LOOK", imageEncoded);
return imageEncoded;
}
// Now trying to use this method to get encoded BASE 64 image in string ..
String final_image = encodeTobase64(mIcon1);
现在,当我尝试将此字符串发送到我的服务器时,然后在服务器端我收到断开的链接......相反,我必须说它不起作用..
我需要做两件事
- 将 Facebook 个人资料图像编码为编码的 BASE 64 字符串,以便将其发送到服务器。
- 获取图像类型(即 PNG/JPG ...)或以一种特定格式压缩和发送该图像。
期待对此提出任何建议。 谢谢!
【问题讨论】:
标签: android facebook base64 encode