TokenCachingStrategy
لم تعد هذه الفئة متوفر في أحدث إصدار من SDK.
يتوفر إصدار أحدث لهذه الفئة. يرجى التحقق أحدث إصدار.

A base class for implementations of a Session token cache.

The Session constructor optionally takes a TokenCachingStrategy, from which it will attempt to load a cached token during construction. Also, whenever the Session updates its token, it will also save the token and associated state to the TokenCachingStrategy.

This is the only mechanism supported for an Android service to use Session. The service can create a custom TokenCachingStrategy that returns the Session provided by an Activity through which the user logged in to Facebook.

الإضافات:Object
الحزمة:facebook
أدوات الإنشاء
TokenCachingStrategy()
public TokenCachingStrategy()
طرق الفئات
hasTokenInformation(Bundle)

Returns a boolean indicating whether a Bundle contains properties that could be a valid saved token.

public static boolean hasTokenInformation(Bundle bundle)
المعلمةالوصف
bundleA Bundle to check for token information.
Returns
A boolean indicating whether a Bundle contains properties that could be a valid saved token.
getToken(Bundle)

Gets the cached token value from a Bundle.

public static String getToken(Bundle bundle)
المعلمةالوصف
bundleA Bundle in which the token value was stored.
Returns
The cached token value, or null.
putToken(Bundle, String)

Puts the token value into a Bundle.

public static void putToken(Bundle bundle, String value)
المعلمةالوصف
bundleA Bundle in which the token value should be stored.
valueThe String representing the token value, or null.
getExpirationDate(Bundle)

Gets the cached expiration date from a Bundle.

public static Date getExpirationDate(Bundle bundle)
المعلمةالوصف
bundleA Bundle in which the expiration date was stored.
Returns
The cached expiration date, or null.
putExpirationDate(Bundle, Date)

Puts the expiration date into a Bundle.

public static void putExpirationDate(Bundle bundle, Date value)
المعلمةالوصف
bundleA Bundle in which the expiration date should be stored.
valueThe Date representing the expiration date.
getExpirationMilliseconds(Bundle)

Gets the cached expiration date from a Bundle.

public static long getExpirationMilliseconds(Bundle bundle)
المعلمةالوصف
bundleA Bundle in which the expiration date was stored.
Returns
The long representing the cached expiration date in milliseconds since the epoch, or 0.
putExpirationMilliseconds(Bundle, long)

Puts the expiration date into a Bundle.

public static void putExpirationMilliseconds(Bundle bundle, long value)
المعلمةالوصف
bundleA Bundle in which the expiration date should be stored.
valueThe long representing the expiration date in milliseconds since the epoch.
getPermissions(Bundle)

Gets the cached list of permissions from a Bundle.

public static List getPermissions(Bundle bundle)
المعلمةالوصف
bundleA Bundle in which the list of permissions was stored.
Returns
The cached list of permissions.
putPermissions(Bundle, List)

Puts the list of permissions into a Bundle.

public static void putPermissions(Bundle bundle, List value)
المعلمةالوصف
bundleA Bundle in which the list of permissions should be stored.
valueThe List<String> representing the list of permissions, or null.
putDeclinedPermissions(Bundle, List)

Puts the list of declined permissions into a Bundle.

public static void putDeclinedPermissions(Bundle bundle, List value)
المعلمةالوصف
bundleA Bundle in which the list of permissions should be stored.
valueThe List<String> representing the list of permissions, or null.
getSource(Bundle)

Gets the cached enum indicating the source of the token from the Bundle.

public static AccessTokenSource getSource(Bundle bundle)
المعلمةالوصف
bundleA Bundle in which the enum was stored.
Returns
Enum indicating the source of the token
putSource(Bundle, AccessTokenSource)

Puts the enum indicating the source of the token into a Bundle.

public static void putSource(Bundle bundle, AccessTokenSource value)
المعلمةالوصف
bundleA Bundle in which the enum should be stored.
valueEnum indicating the source of the token
getLastRefreshDate(Bundle)

Gets the cached last refresh date from a Bundle.

public static Date getLastRefreshDate(Bundle bundle)
المعلمةالوصف
bundleA Bundle in which the last refresh date was stored.
Returns
The cached last refresh Date, or null.
putLastRefreshDate(Bundle, Date)

Puts the last refresh date into a Bundle.

public static void putLastRefreshDate(Bundle bundle, Date value)
المعلمةالوصف
bundleA Bundle in which the last refresh date should be stored.
valueThe Date representing the last refresh date, or null.
getLastRefreshMilliseconds(Bundle)

Gets the cached last refresh date from a Bundle.

public static long getLastRefreshMilliseconds(Bundle bundle)
المعلمةالوصف
bundleA Bundle in which the last refresh date was stored.
Returns
The cached last refresh date in milliseconds since the epoch.
putLastRefreshMilliseconds(Bundle, long)

Puts the last refresh date into a Bundle.

public static void putLastRefreshMilliseconds(Bundle bundle, long value)
المعلمةالوصف
bundleA Bundle in which the last refresh date should be stored.
valueThe long representing the last refresh date in milliseconds since the epoch.
طرق المثيلات
load()

Called during Session construction to get the token state. Typically this is loaded from a persistent store that was previously initialized via save. The caller may choose to keep a reference to the returned Bundle indefinitely. Therefore the TokenCachingStrategy should not store the returned Bundle and should return a new Bundle on every call to this method.

public abstract Bundle load()
Returns
A Bundle that represents the token state that was loaded.
save(Bundle)

Called when a Session updates its token. This is passed a Bundle of values that should be stored durably for the purpose of being returned from a later call to load. Some implementations may choose to store bundle beyond the scope of this call, so the caller should keep no references to the bundle to ensure that it is not modified later.

public abstract void save(Bundle bundle)
المعلمةالوصف
bundleA Bundle that represents the token state to be saved.
clear()

Called when a Session learns its token is no longer valid or during a call to closeAndClearTokenInformation.closeAndClearTokenInformation to clear the durable state associated with the token.

public abstract void clear()
القيم الثابتة
TOKEN_KEY
The key used by Session to store the token value in the Bundle during load and save.
public static final String TOKEN_KEY
EXPIRATION_DATE_KEY
The key used by Session to store the expiration date value in the Bundle during load and save.
public static final String EXPIRATION_DATE_KEY
LAST_REFRESH_DATE_KEY
The key used by Session to store the last refresh date value in the Bundle during load and save.
public static final String LAST_REFRESH_DATE_KEY
USER_FBID_KEY
The key used by Session to store the user's id value in the Bundle during load and save.
public static final String USER_FBID_KEY
TOKEN_SOURCE_KEY
The key used by Session to store an enum indicating the source of the token in the Bundle during load and save.
public static final String TOKEN_SOURCE_KEY
PERMISSIONS_KEY
The key used by Session to store the list of permissions granted by the token in the Bundle during load and save.
public static final String PERMISSIONS_KEY
DECLINED_PERMISSIONS_KEY
The key used by Session to store the list of permissions declined by the user in the token in the Bundle during load and save.
public static final String DECLINED_PERMISSIONS_KEY