我正在寻找跨活动传递 Facebook 会话。我从 Facebook 的 SDK 中看到了这个例子,有人提到“简单”的例子有办法做到这一点:https://github.com/facebook/facebook-android-sdk/blob/master/examples/simple/src/com/facebook/android/SessionStore.java
但这是如何工作的?在我的MainActivity
,我有这个:
mPrefs = getPreferences(MODE_PRIVATE);
String accessToken = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if (accessToken != null) {
//We have a valid session! Yay!
facebook.setAccessToken(accessToken);
}
if (expires != 0) {
//Since we're not expired, we can set the expiration time.
facebook.setAccessExpires(expires);
}
//Are we good to go? If not, call the authentication menu.
if (!facebook.isSessionValid()) {
facebook.authorize(this, new String[] { "email", "publish_stream" }, new DialogListener() {
@Override
public void onComplete(Bundle values) {
}
@Override
public void onFacebookError(FacebookError error) {
}
@Override
public void onError(DialogError e) {
}
@Override
public void onCancel() {
}
});
}
但是我如何将它传递给我的PhotoActivity
活动?有没有实施的例子?