我正在开发一个Android应用程序,我必须在我的应用程序中获取Facebook照片.
在android中有可能吗?
请帮我.
谢谢和问候,durgesh Limbani
Ken*_*nny 11
您只需要用户的用户ID,然后您可以调用这样的函数:
/**
* Function loads the users facebook profile pic
*
* @param userID
*/
public Bitmap getUserPic(String userID) {
String imageURL;
Bitmap bitmap = null;
Log.d(TAG, "Loading Picture");
imageURL = "http://graph.facebook.com/"+userID+"/picture?type=small";
try {
bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
} catch (Exception e) {
Log.d("TAG", "Loading Picture FAILED");
e.printStackTrace();
}
return bitmap;
}
Run Code Online (Sandbox Code Playgroud)
您可以更改imageURL中的类型以获得不同尺寸的图片.
Lon*_*uck 10
对于那些仍在游荡的人:使用facebook SDK,你可以ProfilePictureView在你的xml中实现一个如下所示:
<com.facebook.widget.ProfilePictureView
android:id="@+id/profilePicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:is_cropped="true"
app:preset_size="small" />
Run Code Online (Sandbox Code Playgroud)
然后,一旦你拥有了你的用户ID(必须要求获得那个,但这是另一个故事),你可以ProfilePictureView自己动手并打电话:
ProfilePictureView profilePicture = (ProfilePictureView) view.findViewById(R.id.profilePicture);
profilePicture.setProfileId(userID);
Run Code Online (Sandbox Code Playgroud)
哪里userID是一个String包含用户的ID已经从Facebook的要求.
| 归档时间: |
|
| 查看次数: |
14435 次 |
| 最近记录: |