我的代码可以很好地获取基本的用户信息。但现在我需要用户的电子邮件。我需要在打开的会话上设置权限“电子邮件”。但我不知道在哪里......在打开时,ito 不起作用。这是活动的完整代码
public class MainActivityFB extends Activity {
TextView v;
String FbToken;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.black);
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.color.actionbar));
final List<String> PERMS = new ArrayList<String>(); //= new String[] { "read_stream", "email" }; //set email permision.
// start Facebook Login
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state, Exception exception) {
PERMS.add("read_stream");
PERMS.add("email");
NewPermissionsRequest aa = new NewPermissionsRequest(MainActivityFB.this, PERMS);
System.out.println("Chiamo la richiesta di permessi " + aa.toString());
session.requestNewReadPermissions(aa); //this do nothings. no permision was called
if (session.isOpened()) {
System.out.println("session token " + session.getAccessToken());
FbToken = session.getAccessToken();
// make request to the /me API
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
String nickname = user.getName();
String id = user.getId();
//user.getEmail()... not found
//Do somethings, start the new activity...
finish();
}
}
});
} else {
//Session not open
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
Session session = Session.getActiveSession();
}
我必须在哪里设置阅读电子邮件的新权限?谢谢和对不起我的英语