我想为我的用户添加 facebook 权限。我就是这样做的:
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
List<String> PERMISSIONS = Arrays.asList("email");
if (!session.getPermissions().containsAll(PERMISSIONS)) {
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(MainActivity.this,
PERMISSIONS);
session.requestNewReadPermissions(newPermissionsRequest);
}
Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
Toast.makeText(MainActivity.this, user.asMap().get("email").toString(), Toast.LENGTH_LONG).show();
}
}
}).executeAsync();
}
}
});
问题是我不想每次都打开一个会话,只要用户没有这个权限。有没有办法在本地知道用户是否已经在我的应用中批准了这个权限?