I used the following code to authenticate Facebook, and it works fine, but when I canceled the authentication and tried to authenticate again, the application crashed and the log was called: java.lang.UnsupportedOperationException: Session: an attempt was made to open an already opened session.
On debugging I got this
{Session state:CREATED, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[]}, appId:xxxxxxxxxxxxxxx}
How can I solve this problem. Please help me. thanks in advance
private void askFacebbokAuthentication() { Session session = Session.getActiveSession(); if (session.isOpened()) { facebook = true; if (!hasPublishPermission()) { session.requestNewPublishPermissions(new NewPermissionsRequest( MyActivity.this, PERMISSIONS)); } } else { Session.OpenRequest openRequest = null; openRequest = new Session.OpenRequest(MyActivity.this); if (openRequest != null) { openRequest.setDefaultAudience(SessionDefaultAudience.FRIENDS); if (!hasPublishPermission()) { openRequest.setPermissions(PERMISSIONS); } session.openForPublish(openRequest); } } }
source share