0

I use this in my onSessionStateChange

session.requestNewReadPermissions(new NewPermissionsRequest(this, Arrays.asList("user_photos")));

and i get this error:

java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that has a pending request.

here is the full code of the onSessionStateChange callback.

private void onSessionStateChange(Session session, SessionState state, Exception exception)
    {
        if (state.isOpened())
        {
            Log.i(TAG, "Logged in...");
            m_lblWelcome.setText("You are logged in :)");
            session.requestNewReadPermissions(new NewPermissionsRequest(this, Arrays.asList("user_photos")));

            //Request.executeMeRequestAsync(session, getCurrentLoggedInUser);

        }
        else if (state.isClosed())
        {
            Log.i(TAG, "Logged out...");
            m_lblWelcome.setText("Why did you leave :(");
        }
    }

What am i doing wrong here ?

Mortalus
  • 10,574
  • 11
  • 67
  • 117

1 Answers1

0

You need to call the onActivityResult() method on your current Session when asking for more permissions:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
    uiHelper.onActivityResult(requestCode, resultCode, data);
}
Muhammad Aamir Ali
  • 20,419
  • 10
  • 66
  • 57
  • Why is that? what does onActivityRestult has to do with getting more permissions ? – Mortalus Jul 14 '13 at 02:16
  • So i have added the code but it did not help ... any other suggestion ? – Mortalus Jul 14 '13 at 02:38
  • If you did not add call Session.getActiveSession().onActivityResult(context, requestCode, resltCode, data); Your request would not be completed, and in next request you will get this error as you mentioned. – Muhammad Aamir Ali Jul 14 '13 at 07:08