我正在尝试facebook
从我的应用程序登录并获取用户详细信息。我正在使用我自己的自定义按钮而不是Loginbutton
facebook sdk v3.5。我的问题是,在单击按钮时,询问权限对话框应该出现,让用户同意访问朋友列表、电子邮件等详细信息的权限不来。相反,它会显示加载符号几秒钟,然后直接进入下一个活动。下面是我正在使用的代码。我希望用户单击登录按钮时出现权限对话框。下面是我的代码
fbLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
loginToFb();
}
});
}
private void loginToFb() {
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
final Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
LandingPageActivity.this, Arrays.asList("user_location", "user_birthday", "user_likes", "email"));
session.requestNewReadPermissions(newPermissionsRequest);
// make request to the /me API
Request request = Request.newMeRequest(session,
new Request.GraphUserCallback() {
// callback after Graph API response with user
// object
@Override
public void onCompleted(GraphUser user,
Response response) {
if (user != null) {
fetchUserFbDetails(user);
Intent intent = new Intent(getApplicationContext(),
SignUpActivity.class);
startActivity(intent);
finish();
}
}
}
});
Request.executeBatchAsync(request);
}
}
});
}