我做了以下操作,尝试使用Facebook的Graph API获取用户名。我有登录按钮,但用户总是在onCompleted(..)
上显示为nullprivate 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...");
}
}
答案 0 :(得分:0)
找到解决方案......
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
当然......