gpt4 book ai didi

android - 不登录显示个人资料图片

转载 作者:行者123 更新时间:2023-11-29 20:55:23 25 4
gpt4 key购买 nike

我试图在不实现 Facebook 登录按钮的情况下显示 Facebook 个人资料图片。我正在使用 Facebook SDK。

目前我的头像是这样的:

enter image description here

我成功连接到 Facebook 并使用 com.facebook.widget.ProfilePictureViewxml 中显示空个人资料图片

现在我在尝试检索我的个人资料图片的 java 类中遇到了问题:

游戏.java

@Override
protected void onCreate(Bundle savedInstanceState) {

...
...

// Find the user's profile picture custom view
profilePictureView = (ProfilePictureView) findViewById(R.id.selection_profile_pic);
profilePictureView.setCropped(true);

// view that in turn displays the profile picture.
profilePictureView.setProfileId(GraphUser.getId()); //eror

...
...
}

错误与此行有关:profilePictureView.setProfileId(GraphUser.getId())

在教程中,他们会像这样显示个人资料图片:

        @Override
public void onCompleted(GraphUser user, Response response) {
// If the response is successful
if (session == Session.getActiveSession()) {
if (user != null) {
// Set the id for the ProfilePictureView
// view that in turn displays the profile picture.
profilePictureView.setProfileId(user.getId());
// Set the Textview's text to the user's name.
userNameView.setText(user.getFirstName());
}
}
if (response.getError() != null) {
// Handle errors, will do so later.
}
}

但就我而言,我没有登录 session ,只想加载一张快速个人资料照片。所以我尝试简单地用 profilePictureView.setProfileId(user.getId()); 代替 profilePictureView.setProfileId(GraphUser.getId()); 因为 user 类型为 GraphUser

编译错误:当我编写 profilePictureView.setProfileId(GraphUser.getId()); 时,它说无法从类型 GraphUser 对非静态方法 getId() 进行静态引用

有人可以帮我加载我的个人资料照片吗?如果不先实现 Facebook 登录,这可能吗?

最佳答案

没有授权用户,用户是完全匿名的。所以答案是否定的,没有登录你就不能显示任何东西,而且你当然不能在没有登录的情况下获得用户 ID(这是获得个人资料图片所需要的)。用户 ID 甚至可以让您访问每个用户的真实姓名。当然,未经授权这是不可能的。

有关登录的更多信息(在 Android 上):https://developers.facebook.com/docs/android/login-with-facebook/v2.2

关于android - 不登录显示个人资料图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27910215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com