This class allows some customization of Facebook SDK behavior.
Extends: | Object |
Package: | 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)
Parameter | Description |
---|---|
applicationContext | The application context |
callbackRequestCodeOffset | The 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, int, InitializeCallback)
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, InitializeCallback callback)
Parameter | Description |
---|---|
applicationContext | The application context |
callbackRequestCodeOffset | The 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. |
callback | A callback called when initialize finishes. This will be called even if the sdk is already initialized. |
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)
Parameter | Description |
---|---|
applicationContext | The application context |
sdkInitialize(Context, InitializeCallback)
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, InitializeCallback callback)
Parameter | Description |
---|---|
applicationContext | The application context |
callback | A callback called when initialize finishes. This will be called even if the sdk is already initialized. |
isInitialized()
Indicates whether the Facebook SDK has been initialized.
public static synchronized boolean isInitialized()
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()
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)
Parameter | Description |
---|---|
behavior | The 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)
Parameter | Description |
---|---|
behavior | The 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)
Parameter | Description |
---|---|
behavior | The LoggingBehavior to check |
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)
Parameter | Description |
---|---|
enabled | Debug 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()
setLegacyTokenUpgradeSupported(boolean)
Setter for legacy token upgrade.
public static void setLegacyTokenUpgradeSupported(boolean supported)
Parameter | Description |
---|---|
supported | True 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()
setExecutor(Executor)
Sets the Executor used by the SDK for non-AsyncTask background work.
public static void setExecutor(Executor executor)
Parameter | Description |
---|---|
executor | The 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()
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)
Parameter | Description |
---|---|
facebookDomain | The base domain to use instead of "facebook.com" |
getApplicationContext()
The getter for the context of the current application.
public static Context getApplicationContext()
setGraphApiVersion(String)
Sets the Graph API version to use when making Graph requests. This defaults to the latest Graph API version at the time when the Facebook SDK is shipped.
public static void setGraphApiVersion(String graphApiVersion)
Parameter | Description |
---|---|
graphApiVersion | The Graph API version, it should be of the form "v2.7" |
getGraphApiVersion()
Returns the Graph API version to use when making Graph requests. This defaults to the latest Graph API version at the time when the Facebook SDK is shipped.
public static String getGraphApiVersion()
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)
Parameter | Description |
---|---|
context | The application context. |
applicationId | The application id. |
getSdkVersion()
Returns the current version of the Facebook SDK for Android as a string.
public static String getSdkVersion()
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)
Parameter | Description |
---|---|
context | Used 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)
Parameter | Description |
---|---|
context | Used 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)
Parameter | Description |
---|---|
threshold | The number of bytes progressed to force a callback. |
getApplicationSignature(Context)
Internal call please don't use directly.
public static String getApplicationSignature(Context context)
Parameter | Description |
---|---|
context | The application context. |
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()
setApplicationId(String)
Sets the Facebook application ID for the current app.
public static void setApplicationId(String applicationId)
Parameter | Description |
---|---|
applicationId | The 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()
setApplicationName(String)
Sets the Facebook application name for the current app.
public static void setApplicationName(String applicationName)
Parameter | Description |
---|---|
applicationName | The 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()
setClientToken(String)
Sets the Facebook client token for the current app.
public static void setClientToken(String clientToken)
Parameter | Description |
---|---|
clientToken | The client token |
getWebDialogTheme()
Gets the theme used by WebDialog
public static int getWebDialogTheme()
setWebDialogTheme(int)
Sets the theme used by WebDialog
public static void setWebDialogTheme(int theme)
Parameter | Description |
---|---|
theme | A theme to use |
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()
setCacheDir(File)
Sets the cache directory to use for caching responses, etc.
public static void setCacheDir(File cacheDir)
Parameter | Description |
---|---|
cacheDir | The 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()
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)
Parameter | Description |
---|---|
requestCode | The request code to check. |
APPLICATION_ID_PROPERTY
public static final String APPLICATION_ID_PROPERTY
APPLICATION_NAME_PROPERTY
public static final String APPLICATION_NAME_PROPERTY
CLIENT_TOKEN_PROPERTY
public static final String CLIENT_TOKEN_PROPERTY
WEB_DIALOG_THEME
public static final String WEB_DIALOG_THEME