Java – Session : an attempt was made to open a session that has a pending request

Session : an attempt was made to open a session that has a pending request… here is a solution to the problem.

Session : an attempt was made to open a session that has a pending request

I’m using a simple Facebook API for Android, but I’m having an issue here.

I’m logging in with the code on their website https://github.com/sromku/android-simple-facebook and obtain profile information.

It works. When I click on my “Sign in” button, it shows the Facebook login page, then after logging in it goes to authorization and goes back to my app and it works.

However, if I click Sign in, then close the login dialog that opens with the Facebook login page, and try to log in again, I get this exception:

ERROR/Facebook(17472): Bad thing happened
java.lang.UnsupportedOperationException: Session: an attempt was made
to open a session that has a pending request. at
com.facebook.Session.open(Session.java:958) at
com.facebook.Session.openForRead(Session.java:388) at
com.sromku.simple.fb.SimpleFacebook.openSession(SimpleFacebook.java:680)
at com.sromku.simple.fb.SimpleFacebook.login(SimpleFacebook.java:255)

Any ideas?

Solution

Just fixed this issue.

Must be added

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    mSimpleFacebook.onActivityResult(this, requestCode, resultCode, data); 
    super.onActivityResult(requestCode, resultCode, data);
} 

My Activities.

Related Problems and Solutions