Facebook getName()

时间:2015-01-18 23:00:14

标签: android facebook

我做了以下操作,尝试使用Facebook的Graph API获取用户名。我有登录按钮,但用户总是在onCompleted(..)

上显示为null
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
    if (state.isOpened()) {
        Log.i(TAG, "Logged in..." + session.toString());

        // Request user data and show the results
        Request.newMeRequest(session, new Request.GraphUserCallback() {
                    public void onCompleted(GraphUser user, Response response) {
                        if (user == null)
                        {
                            Log.i("", "no!");
                        }
                        else {
                            Log.i("", "YES " + user.getName());
                        }
                    }
                }
        ).executeAsync();

    } else if (state.isClosed()) {
        Log.i(TAG, "Logged out...");
    }
}

1 个答案:

答案 0 :(得分:0)

找到解决方案......

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

当然......