简体   繁体   English

Android Facebook SDK-用户名变为空

[英]Android Facebook SDK - username is getting null

I am using simple facebbok to integrate facebook to my application.i need to send the facebook username to server.but i got the username as null from profile listner. 我正在使用简单的facebbok将Facebook集成到我的应用程序中。我需要将Facebook用户名发送到server。但是我从配置文件列表器中获得了用户名null。 here is my code 这是我的代码

   public void loginToFacebook(View v){
    mSimpleFacebook.login(this);
}
OnLoginListener listner = new OnLoginListener() {
    @Override
    public void onLogin() {
        mSimpleFacebook.getProfile(onProfileListener);
    }
};
OnProfileListener onProfileListener = new OnProfileListener() {         
    @Override
    public void onComplete(Profile profile) {
        System.out.println(profile.getUsername());//getting null here
    }
};

I have also tried with the code, 我也尝试过使用代码

OnLoginListener listner = new OnLoginListener() {
    @Override
    public void onLogin() {
    Profile.Properties properties = new Profile.Properties.Builder()
    .add(Properties.USER_NAME)
    .add(Properties.ID)
    .build();
    mSimpleFacebook.getProfile(properties, onProfileListener);
    }
};

But the listner is not getting fired in this case. 但是在这种情况下,列表器不会被解雇。

This is the permission i have given in the Application class 这是我在Application类中给予的许可

private void configureFacebook() {
       Permission[] permissions = new Permission[] {
                Permission.USER_ABOUT_ME,
                Permission.PUBLIC_PROFILE,
                Permission.READ_STREAM,
                Permission.EMAIL,
                Permission.PUBLISH_ACTION
            };
       SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
        .setAppId(Constants.FB_APPID)
        .setNamespace("namespace")
        .setPermissions(permissions)
        .build();
       SimpleFacebook.setConfiguration(configuration);
}

您无法在API v2.0中获取用户名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 适用于Android的Facebook SDK-通过传递用户名和密码来获取访问令牌 - Facebook SDK for android - getting access token by passing username and password 在 Facebook SDK 4 android 中获取用户名 - Get username in Facebook SDK 4 android 使用Facebook android SDK访问Facebook用户名 - Accessing Facebook username using Facebook android SDK Android Facebook SDK 3.2 获取个人资料电子邮件信息显示为空 - Android Facebook SDK 3.2 Getting Profile Email information Showing Null Android Facebook SDK 4.0-显示用户名 - Android Facebook SDK 4.0 - Display username 适用于Android的Facebook SDK入门 - Getting Started with the facebook sdk for android Android Facebook sdk 4.0:获取Facebook用户信息时为空异常? - Android Facebook sdk 4.0 : Null exception while getting facebook user information? Facebook登录名获取用户名,但配置文件电子邮件显示我的Android应用程序为空 - Facebook Login Getting Username,But Profile email Showing Null from my Android app Android Facebook SDK无法获取Facebook个人资料图片 - Android Facebook SDK not getting Facebook profile picture 在Facebook SDK集成中获取空电子邮件地址 - Getting null email address in facebook sdk integration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM