0

I would like to implement an android app requires facebook login in the beginning. As I declare the facebook object in main activity and want to invoke facebook.authorize in another activity, but I can't put the facebook object to intent, is there other way to achieve this?

Here is the flow: When the app is first opened, a main activity is opened. It will then check if the access token is set, if no, a new activity is started to let user login. In that activity there are some login option and a login button. If user press the login button, facebook api is called to do the login.

4

1 回答 1

1

You can use a similar method that is used in the official facebook/android examples.
Using the SessionStore you can do something like:

First activity:

Facebook facebook = new Facebook("APP_ID");
if (!SessionStore.restore(facebook, this)) {
    // start the other activity for authentication
}

Second activity:

Facebook facebook = new Facebook("APP_ID");
facebook.authorize(this, new DialogListener() {
    @Override
    public void onComplete(Bundle values) {
        SessionStore.restore(facebook, this)
    }
    ...
});
于 2012-06-11T16:53:07.490 回答