Android Facebook SDK 3.0 auth

I actually follow the SessionLoginFragment.java example from facebook sdk samples.

What I really don't understand is:

when i do

session.openForRead(new Session.OpenRequest(fragment).setCallback(statusCallback)); 

to register my user on facebook and request a basic read permission (just check integration), it just doesn't work.

I dug up the debugger a bit and I went down the path. If you do not put requestCode in an OpenRequest session, it will give it random (and that’s fine).

openForRead (my actual session is in CREATED state) will create a permission dialog. When you click the "Ok" button, it will execute

 request.getStartActivityDelegate().startActivityForResult(intent, request.getRequestCode()); 

You can see the code from fb sdk source code. Well, requestCode is the same session (and good here).

When fb registers you with the system, it will complete its facebook.LoginActivity and call me back my onActivityResult in my activity. The problem is that here requestCode is different from the request. And I don’t know why and where it comes from!

If I log in to my fb account, my application will be there, so that means that I did the correct authentication flow, which ends well. But due to this problem, I will not be able to authenticate correctly from my application.

Do you know why and how I can solve it?

Thanks.

UPDATE WITH FLOW DETAILS:

This is the actual stream (from fragment ):

 session.openForRead(new Session.OpenRequest(fragment).setCallback(statusCallback)); 

After creating it, the request code is (always) 64206 Now, the openForRead thread will call (the final part)

 request.getStartActivityDelegate().startActivityForResult(intent, request.getRequestCode()); 

To do this, call the LoginActivity function from the SDK from facebook and perform a client / server / oauth check

Now my activity is called onActivityResult (not a fragment, but part of the activity)

and here I call

 Session.getActiveSession().onActivityResult(activity, requestCode, resultCode, data); 

And here requestCode is requestCode 129742

How is this possible? As I said, the problem in this whole thread is that the requestCode returned by onActivityResult is different from my requestCode request and this break (getActiveSession (). OnActivityResult returns without client code) the client part of the input.

+7
source share
2 answers

I ran into the same problem, except in my case, the insult to 326350 was 326350 ( 0x4face ). And I really called super.onActivityResult , so a workaround

+5
source

Just ran into this problem. The difference between 64206 (0xface) and 129742 (0x1face) is that FragmentActivity set an additional 0x10000 to determine which fragment it came from. This was allowed by making sure that super activity was triggered during onActivityResult

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

"You can only use the lower 16 bits for requestCode," as indicated in FragmentActivity.startActivityFromFragment

+4
source

All Articles