我有一个问题,我的应用程序弹出框有两个权限。第一个是 “Explovia希望访问您的公开个人资料和朋友列表”,第二个是 “Explovia想要访问您的公开个人资料和朋友列表,电子邮件”。
如何将这两个设置为一个?因为第二个基本上是要求与第一个+电子邮件相同的许可,是第一个许可然后真的是必要的吗?
// Create session and make Request object with all permisssions listed
Session s = new Session(mActivity);
Session.OpenRequest request = new Session.OpenRequest(mActivity);
request.setPermissions(Arrays.asList("email"));
request.setCallback(mCallback);
s.openForRead(request);
编辑:添加了回调代码
private Session.StatusCallback mCallback = new Session.StatusCallback() {
@SuppressWarnings("deprecation")
@Override
public void call(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
// 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,
com.facebook.Response response) {
try {
editEmail.setText((String) user.getProperty("email").toString());
}catch(Exception e){
Toast.makeText(mActivity,"We couldn't retrieve your email because you didn't confirm your email!",Toast.LENGTH_LONG).show();
}
editName.setText(user.getFirstName());
editSurname.setText(user.getLastName());
// We must have try-catch here because if user doesn't have confirmed email, app will crash
// Get user id because we will need it later to access
// user profile picture(graph.facebook.com/uId/picture?width=x&height=x)
uId = user.getId().toString();
String url = "https://graph.facebook.com/"+uId+"/picture?width=200&height=200";
imagePhoto.setTag(url);
new DownloadImagesTask().execute(imagePhoto);
// Delete created session because we don't need it anymore
Session.getActiveSession().closeAndClearTokenInformation();
Session.setActiveSession(null);
}
});
}
}
};
答案 0 :(得分:0)
好吧我想我在Session.openActiveSession(Activity,Boolean,Status.CallBack)中找到了解决方案,我在布尔参数中输入false,现在它可以工作。