首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在没有登录的情况下显示个人资料图片

问在没有登录的情况下显示个人资料图片
EN

Stack Overflow用户
提问于 2015-01-12 20:27:53
回答 1查看 718关注 0票数 1

我试图显示一个Facebook的个人资料图片,而没有实现Facebook登录按钮。我正在使用Facebook。

目前,我的个人资料图片如下:

​

​

我成功地连接到Facebook,并使用com.facebook.widget.ProfilePictureView在xml中显示一个空的配置文件图片。

现在,我的java类在检索我的配置文件图片时遇到了困难:

Game.java

代码语言:javascript
复制
@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())

在本教程中,它们显示的配置文件图片如下:

代码语言:javascript
复制
        @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.
            }
        }

但在我的情况下,我没有登录会话,我只是想加载一个快速的个人资料照片。所以我试着简单地用profilePictureView.setProfileId(user.getId());代替profilePictureView.setProfileId(GraphUser.getId());,因为user是GraphUser类型的

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

谁能帮我载入我的个人资料照片吗?如果不首先实现Facebook登录,这是可能的吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-12 20:44:18

在不授权用户的情况下,用户是完全匿名的。所以答案是否定的,没有登录就不能显示任何东西,当然没有登录就无法获得用户ID (这就是获取配置文件图片所需要的)。用户ID甚至允许您访问每个用户的真实名称。当然,如果没有授权,那是不可能的。

关于登录(安卓)的更多信息:https://developers.facebook.com/docs/android/login-with-facebook/v2.2

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27910215

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档