登录和询问权限工作得很好。但是有一个问题:当用户想要从我的应用程序共享某个日期时,我需要询问发布权限。这是我的代码:
ParseFacebookUtils.getSession().requestNewPublishPermissions(new NewPermissionsRequest((Activity) context,
Arrays.asList(Permissions.Extended.PUBLISH_ACTIONS, Permissions.Extended.PUBLISH_STREAM))
.setCallback(new StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (!arePublishPermissionsEnabled(session)) {
inflow.setChecked(false);
facebook.setChecked(false);
twitter.setChecked(false);
}
}
}));
问题在于用户取消请求或网络连接丢失时的处理情况。在这种情况下,我需要在我的UI中进行一些更改,但方法调用仅在会话状态更改时调用(例如,授予新权限)并且我无法正确更改UI。有人遇到过这样的问题吗?
答案 0 :(得分:1)
private void requestPublishPermissions(Session session) {
List<String> PERMISSIONS = Arrays.asList("publish_actions", "publish_stream");
if (session != null) {
pendingAnnounce = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS);
newPermissionsRequest.setRequestCode(REAUTH_ACTIVITY_CODE);
Session mSession = Session.openActiveSessionFromCache(this);
mSession.addCallback(callback);
mSession.requestNewPublishPermissions(newPermissionsRequest);
}
}