FacebookSdk
有此級別的更新版本。前往查看 最新版本。

This class allows some customization of Facebook SDK behavior.

伸延:Object
套件:facebook
建構函式
FacebookSdk()
public FacebookSdk()
類別方式
sdkInitialize(Context, int)

This function initializes the Facebook SDK, the behavior of Facebook SDK functions are undetermined if this function is not called. It should be called as early as possible.

public static synchronized void sdkInitialize(Context applicationContext, int callbackRequestCodeOffset)
參數說明
applicationContextThe application context
callbackRequestCodeOffsetThe request code offset that Facebook activities will be called with. Please do not use the range between the value you set and another 100 entries after it in your other requests.
sdkInitialize(Context)

This function initializes the Facebook SDK, the behavior of Facebook SDK functions are undetermined if this function is not called. It should be called as early as possible.

public static synchronized void sdkInitialize(Context applicationContext)
參數說明
applicationContextThe application context
isInitialized()

Indicates whether the Facebook SDK has been initialized.

public static synchronized boolean isInitialized()
Returns
True if initialized, false if not
getLoggingBehaviors()

Certain logging behaviors are available for debugging beyond those that should be enabled in production.

Returns the types of extended logging that are currently enabled.

public static Set getLoggingBehaviors()
Returns
A set containing enabled logging behaviors
addLoggingBehavior(LoggingBehavior)

Certain logging behaviors are available for debugging beyond those that should be enabled in production.

Enables a particular extended logging in the SDK.

public static void addLoggingBehavior(LoggingBehavior behavior)
參數說明
behaviorThe LoggingBehavior to enable
removeLoggingBehavior(LoggingBehavior)

Certain logging behaviors are available for debugging beyond those that should be enabled in production.

Disables a particular extended logging behavior in the SDK.

public static void removeLoggingBehavior(LoggingBehavior behavior)
參數說明
behaviorThe LoggingBehavior to disable
clearLoggingBehaviors()

Certain logging behaviors are available for debugging beyond those that should be enabled in production.

Disables all extended logging behaviors.

public static void clearLoggingBehaviors()
isLoggingBehaviorEnabled(LoggingBehavior)

Certain logging behaviors are available for debugging beyond those that should be enabled in production.

Checks if a particular extended logging behavior is enabled.

public static boolean isLoggingBehaviorEnabled(LoggingBehavior behavior)
參數說明
behaviorThe LoggingBehavior to check
Returns
Whether behavior is enabled
isDebugEnabled()

Indicates if we are in debug mode.

public static boolean isDebugEnabled()
setIsDebugEnabled(boolean)

Used to enable or disable logging, and other debug features. Defaults to BuildConfig.DEBUG.

public static void setIsDebugEnabled(boolean enabled)
參數說明
enabledDebug features (like logging) are enabled if true, disabled if false.
isLegacyTokenUpgradeSupported()

Indicates if the SDK should fallback and read the legacy token. This is turned off by default for performance.

public static boolean isLegacyTokenUpgradeSupported()
Returns
If the legacy token upgrade is supported.
setLegacyTokenUpgradeSupported(boolean)

Setter for legacy token upgrade.

public static void setLegacyTokenUpgradeSupported(boolean supported)
參數說明
supportedTrue if upgrade should be supported.
getExecutor()

Returns the Executor used by the SDK for non-AsyncTask background work.

By default this uses AsyncTask Executor via reflection if the API level is high enough. Otherwise this creates a new Executor with defaults similar to those used in AsyncTask.

public static Executor getExecutor()
Returns
An Executor used by the SDK. This will never be null.
setExecutor(Executor)

Sets the Executor used by the SDK for non-AsyncTask background work.

public static void setExecutor(Executor executor)
參數說明
executorThe Executor to use; must not be null.
getFacebookDomain()

Gets the base Facebook domain to use when making Web requests; in production code this will always be "facebook.com".

public static String getFacebookDomain()
Returns
The Facebook domain
setFacebookDomain(String)

Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com", but may be overridden to, e.g., "beta.facebook.com" to direct requests at a different domain. This method should never be called from production code.

public static void setFacebookDomain(String facebookDomain)
參數說明
facebookDomainThe base domain to use instead of "facebook.com"
getApplicationContext()

The getter for the context of the current application.

public static Context getApplicationContext()
Returns
The context of the current application.
publishInstallAsync(Context, String)

This method is public in order to be used by app events, please don't use directly.

public static void publishInstallAsync(Context context, String applicationId)
參數說明
contextThe application context.
applicationIdThe application id.
getAttributionId(ContentResolver)

Returns the current attribution id from the facebook app.

public static String getAttributionId(ContentResolver contentResolver)
參數說明
contentResolver
Returns
Null if the facebook app is not present on the phone.
getSdkVersion()

Returns the current version of the Facebook SDK for Android as a string.

public static String getSdkVersion()
Returns
The current version of the SDK
getLimitEventAndDataUsage(Context)

Returns whether data such as those generated through AppEventsLogger and sent to Facebook should be restricted from being used for purposes other than analytics and conversions, such as targeting ads to this user. Defaults to false. This value is stored on the device and persists across app launches.

public static boolean getLimitEventAndDataUsage(Context context)
參數說明
contextUsed to read the value.
setLimitEventAndDataUsage(Context, boolean)

Sets whether data such as those generated through AppEventsLogger and sent to Facebook should be restricted from being used for purposes other than analytics and conversions, such as targeting ads to this user. Defaults to false. This value is stored on the device and persists across app launches. Changes to this setting will apply to app events currently queued to be flushed.

public static void setLimitEventAndDataUsage(Context context, boolean limitEventUsage)
參數說明
contextUsed to persist this value across app runs.
limitEventUsage
getOnProgressThreshold()

Gets the threshold used to report progress on requests.

public static long getOnProgressThreshold()
setOnProgressThreshold(long)

Sets the threshold used to report progress on requests. Note that the value will be read when the request is started and cannot be changed during a request (or batch) execution.

public static void setOnProgressThreshold(long threshold)
參數說明
thresholdThe number of bytes progressed to force a callback.
getApplicationSignature(Context)

Internal call please don't use directly.

public static String getApplicationSignature(Context context)
參數說明
contextThe application context.
Returns
The application signature.
getApplicationId()

Gets the Facebook application ID for the current app. This should only be called after the SDK has been initialized by calling FacebookSdk.sdkInitialize().

public static String getApplicationId()
Returns
The application ID
setApplicationId(String)

Sets the Facebook application ID for the current app.

public static void setApplicationId(String applicationId)
參數說明
applicationIdThe application ID
getApplicationName()

Gets the Facebook application name of the current app. This should only be called after the SDK has been initialized by calling FacebookSdk.sdkInitialize().

public static String getApplicationName()
Returns
The application name
setApplicationName(String)

Sets the Facebook application name for the current app.

public static void setApplicationName(String applicationName)
參數說明
applicationNameThe application name
getClientToken()

Gets the client token for the current app. This will be null unless explicitly set or unless loadDefaultsFromMetadata has been called.

public static String getClientToken()
Returns
The client token
setClientToken(String)

Sets the Facebook client token for the current app.

public static void setClientToken(String clientToken)
參數說明
clientTokenThe client token
getCacheDir()

Gets the cache directory to use for caching responses, etc. The default will be the value returned by Context.getCacheDir() when the SDK was initialized, but it can be overridden.

public static File getCacheDir()
Returns
The cache directory
setCacheDir(File)

Sets the cache directory to use for caching responses, etc.

public static void setCacheDir(File cacheDir)
參數說明
cacheDirThe cache directory
getCallbackRequestCodeOffset()

Getter for the callback request code offset. The request codes starting at this offset and the next 100 values are used by the Facebook SDK.

public static int getCallbackRequestCodeOffset()
Returns
The callback request code offset.
isFacebookRequestCode(int)

Returns true if the request code is within the range used by Facebook SDK requests. This does not include request codes that you explicitly set on the dialogs, buttons or LoginManager. The range of request codes that the SDK uses starts at the callbackRequestCodeOffset and continues for the next 100 values.

public static boolean isFacebookRequestCode(int requestCode)
參數說明
requestCodeThe request code to check.
Returns
True if the request code is within the range used by the Facebook SDK.
常數
APPLICATION_ID_PROPERTY
The key for the application ID in the Android manifest.
public static final String APPLICATION_ID_PROPERTY
APPLICATION_NAME_PROPERTY
The key for the application name in the Android manifest.
public static final String APPLICATION_NAME_PROPERTY
CLIENT_TOKEN_PROPERTY
The key for the client token in the Android manifest.
public static final String CLIENT_TOKEN_PROPERTY