Arb*_*ind 0 java android facebook image facebook-graph-api
URL1:从Facebook获取图片的网址:http://graph.facebook.com/ {fb-user-id}/picture?type = large
URL2:URL1被点击时重定向的URL https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t5.0-1/371818_100002856860463_136071413_n.jpg
Facebook个人资料图片未显示在图片视图android中.这可能是因为从facebook获取图像的url即URL1重定向到某个其他位置以提供图像.当我直接使用重定向的URL即URL2加载图像时,它工作正常.
获取位图的代码:
Bitmap b = null;
URL url = null;
try {
url = new URL(image_path);
URLConnection dd = url.openConnection();
b = BitmapFactory.decodeStream(dd.getInputStream());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我已经google了很多,我得到了stackoverflow本身的一些答案(可能是一个可能重复),但没有得到任何可以解决这个问题的答案.提前致谢.
您可以使用Facebook ProfilePictureView而不是Imageview来实现它
<com.facebook.login.widget.ProfilePictureView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
facebook:preset_size="small"/>
Run Code Online (Sandbox Code Playgroud)
之后你可以在代码中设置这样的facebook id
ProfilePictureView profilePictureView;
profilePictureView = (ProfilePictureView)findViewById(R.id.friendProfilePicture);
profilePictureView.setProfileId(userId);
Run Code Online (Sandbox Code Playgroud)
它的工作原理..
你也可以为ProfilePictureView设置小/普通/大/自定义的大小
归档时间: |
|
查看次数: |
1950 次 |
最近记录: |