简体   繁体   中英

Facebook Android SDK Does Not Allow Consecutive Posting To Facebook Wall?

I have been struggling with this issue for weeks now and I don't want to give up! Here is my problem:

Problem Definition

I have successfully logged in a Facebook user using Facebook SDK. This happens immediately after they choose a photo to share on their wall.

The first attempt to post the image works effortlessly and the user gets redirected to a different view once they are done posting to their wall.

Here is where things don't work:

When the user tries to login again to post another photo for instance, they are allowed to login but then the screen goes blank and nothing gets posted to their Facebook wall.

I don't know why it is acting like this and I cannot figure out where it dies exactly.

Things I have tried so far

I have, since I am making three async calls, created a timer (Thread) which checks to see if the calls have been completed, then calls:

Session.getActiveSession().closeAndClearTokenInformation();

This, does not solve the problem.

I have also tried using a counter variable that gets incremented each time an async task is completed and then I check to see if the number is 3 before clearing everything up. This still fails.

I am stuck and I really need your help. Sorry for the long question - I just thought I should give enough details.

Thanks, E

I ended up solving this problem on my own and here is what I did:

  1. Define a local variable called isPosted which is a boolean and set its initial state to false.
  2. In the first async task, either do nothing with it inside onCompleted() method or set it to false again just in case something set it to true;
  3. Repeat this until you reach the last async task - the one to be executed last.
  4. In the last request/async, set it to true.
  5. After calling the methods that execute those async tasks, check to see if the variable is true - in that case, clear the session and token information. If needed, clear the cookies as well. This will logout the user completely and create room room for others.

This enabled multiple users to login one after another and a single user can login consecutively without issues and post to their wall.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM