Android SDK Version


public class FacebookSdk
This class allows some customization of Facebook SDK behavior.
Nested Class Summary
Modifier and TypeClassDescription
public interfaceFacebookSdk.InitializeCallback
Callback passed to the sdkInitialize function.
Method Summary
Modifier and TypeMethodDescription
final static ExecutorgetExecutor() Returns the Executor used by the SDK for non-AsyncTask background work.
final static UnitsetExecutor(Executor executor) Sets the Executor used by the SDK for non-AsyncTask background work.
final static LonggetOnProgressThreshold() Gets the threshold used to report progress on requests.
final static UnitsetOnProgressThreshold(Long threshold) Sets the threshold used to report progress on requests.
final static BooleanisDebugEnabled() Indicates if we are in debug mode.
final static UnitsetIsDebugEnabled(Boolean enabled) Used to enable or disable logging, and other debug features.
final static BooleanisLegacyTokenUpgradeSupported() Indicates if the SDK should fallback and read the legacy token.
final static UnitsetLegacyTokenUpgradeSupported(Boolean supported) Setter for legacy token upgrade.
final static StringgetGraphApiVersion() Returns the Graph API version to use when making Graph requests.
final static UnitsetGraphApiVersion(String graphApiVersion) Sets the Graph API version to use when making Graph requests.
final static BooleanisFullyInitialized() Indicates whether the Facebook SDK has been fully initialized.
final static StringgetFacebookDomain() Gets the base Facebook domain to use when making Web Requests; in production code this will always be "facebook.com".
final static StringgetInstagramDomain() Gets the base Instagram domain to use when making Web Requests; in production code this will always be "instagram.com".
final static UnitsetFacebookDomain(String facebookDomain) Sets the base Facebook domain to use when making Web requests.
final static UnitsdkInitialize(Context applicationContext, Integer callbackRequestCodeOffset) This function initializes the Facebook SDK.
final static UnitsdkInitialize(Context applicationContext, Integer callbackRequestCodeOffset, FacebookSdk.InitializeCallback callback) This function initializes the Facebook SDK.
final static UnitsdkInitialize(Context applicationContext) This function initializes the Facebook SDK.
final static UnitsdkInitialize(Context applicationContext, FacebookSdk.InitializeCallback callback) This function initializes the Facebook SDK.
final static BooleanisInitialized() Indicates whether the Facebook SDK has been initialized.
final static UnitfullyInitialize() Mark Facebook SDK fully initialized to make it works as expected.
final static Set<LoggingBehavior>getLoggingBehaviors() Certain logging behaviors are available for debugging beyond those that should be enabled in production.
final static UnitaddLoggingBehavior(LoggingBehavior behavior) Certain logging behaviors are available for debugging beyond those that should be enabled in production.
final static UnitremoveLoggingBehavior(LoggingBehavior behavior) Certain logging behaviors are available for debugging beyond those that should be enabled in production.
final static UnitclearLoggingBehaviors() Certain logging behaviors are available for debugging beyond those that should be enabled in production.
final static BooleanisLoggingBehaviorEnabled(LoggingBehavior behavior) Certain logging behaviors are available for debugging beyond those that should be enabled in production.
final static StringgetGraphDomain() Gets the base Facebook domain to use when making Graph API requests; in production code this will normally be "facebook.com".
final static ContextgetApplicationContext() The getter for the context of the current application.
final static UnitpublishInstallAsync(Context context, String applicationId) This method is public in order to be used by app events, please don't use directly.
final static StringgetSdkVersion() Returns the current version of the Facebook SDK for Android as a string.
final static BooleangetLimitEventAndDataUsage(Context 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.
final static UnitsetLimitEventAndDataUsage(Context context, Boolean limitEventUsage) 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.
final static StringgetApplicationSignature(Context context) Internal call please don't use directly.
final static StringgetApplicationId() Gets the Facebook application ID for the current app.
final static UnitsetApplicationId(String applicationId) Sets the Facebook application ID for the current app.
final static StringgetApplicationName() Gets the Facebook application name of the current app.
final static UnitsetApplicationName(String applicationName) Sets the Facebook application name for the current app.
final static StringgetClientToken() Gets the client token for the current app.
final static UnitsetClientToken(String clientToken) Sets the Facebook client token for the current app.
final static BooleangetAutoInitEnabled()
final static UnitsetAutoInitEnabled(Boolean flag) Sets the auto init SDK flag for the application
final static BooleangetAutoLogAppEventsEnabled() Gets the flag used by com.facebook.appevents.AppEventsLogger
final static UnitsetAutoLogAppEventsEnabled(Boolean flag) Sets the auto logging events flag for the application com.facebook.appevents.AppEventsLogger
final static BooleangetCodelessDebugLogEnabled()
final static BooleangetCodelessSetupEnabled()
final static BooleangetAdvertiserIDCollectionEnabled()
final static UnitsetAdvertiserIDCollectionEnabled(Boolean flag) Sets the advertiserID collection flag for the application
final static UnitsetCodelessDebugLogEnabled(Boolean flag) Sets the codeless debug flag for the application
final static BooleangetMonitorEnabled() Gets the flag of Monitor Feature
final static UnitsetMonitorEnabled(Boolean flag) Sets the monitor flag for the application
final static UnitsetDataProcessingOptions(Array<String> options) Sets data processing options
final static UnitsetDataProcessingOptions(Array<String> options, Integer country, Integer state) Sets data processing options
final static FilegetCacheDir() Gets the cache directory to use for caching responses, etc.
final static UnitsetCacheDir(File cacheDir) Sets the cache directory to use for caching responses, etc.
final static IntegergetCallbackRequestCodeOffset() Getter for the callback request code offset.
final static BooleanisFacebookRequestCode(Integer requestCode) Returns true if the request code is within the range used by Facebook SDK requests.
final StringgetCALLBACK_OFFSET_CHANGED_AFTER_INIT()
final StringgetCALLBACK_OFFSET_NEGATIVE()
final StringgetAPP_EVENT_PREFERENCES() The key for AppEvent perfernece setting.
final StringgetDATA_PROCESSING_OPTIONS_PREFERENCES() The key for the data processing options preference setting.
final StringgetAPPLICATION_ID_PROPERTY() The key for the application ID in the Android manifest.
final StringgetAPPLICATION_NAME_PROPERTY() The key for the application name in the Android manifest.
final StringgetCLIENT_TOKEN_PROPERTY() The key for the client token in the Android manifest.
final StringgetWEB_DIALOG_THEME() The key for the web dialog theme in the Android manifest.
final StringgetAUTO_INIT_ENABLED_PROPERTY() The key for the auto init SDK in the Android manifest.
final StringgetAUTO_LOG_APP_EVENTS_ENABLED_PROPERTY() The key for the auto logging app events in the Android manifest.
final StringgetCODELESS_DEBUG_LOG_ENABLED_PROPERTY() The key for the auto log codeless in the Android manifest.
final StringgetADVERTISER_ID_COLLECTION_ENABLED_PROPERTY() The key for the advertiserID collection in the Android manifest.
final StringgetCALLBACK_OFFSET_PROPERTY() The key for the callback off set in the Android manifest.
final StringgetMONITOR_ENABLED_PROPERTY() The key for the monitor enable in the Android manifest.
final StringgetDATA_PROCESSION_OPTIONS() The key for modes in data processing options.
final StringgetDATA_PROCESSION_OPTIONS_COUNTRY() The key for country in data processing options.
final StringgetDATA_PROCESSION_OPTIONS_STATE() The key for state in data processing options.
final BooleangetHasCustomTabsPrefetching()
final UnitsetHasCustomTabsPrefetching(@JvmField() Boolean hasCustomTabsPrefetching)
final BooleangetIgnoreAppSwitchToLoggedOut()
final UnitsetIgnoreAppSwitchToLoggedOut(@JvmField() Boolean ignoreAppSwitchToLoggedOut)
final BooleangetBypassAppSwitch()
final UnitsetBypassAppSwitch(@JvmField() Boolean bypassAppSwitch)
final StringgetINSTAGRAM()
final StringgetGAMING()
final StringgetFACEBOOK_COM()
final StringgetFB_GG()
final StringgetINSTAGRAM_COM()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Method Detail

getExecutor

 final static ExecutorgetExecutor()
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.

setExecutor

 final static UnitsetExecutor(Executor executor)
Sets the Executor used by the SDK for non-AsyncTask background work.
Parameters:
executor - the Executor to use; must not be null.

getOnProgressThreshold

 final static LonggetOnProgressThreshold()
Gets the threshold used to report progress on requests.

setOnProgressThreshold

 final static UnitsetOnProgressThreshold(Long threshold)
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.
Parameters:
threshold - The number of bytes progressed to force a callback.

isDebugEnabled

 final static BooleanisDebugEnabled()
Indicates if we are in debug mode.

setIsDebugEnabled

 final static UnitsetIsDebugEnabled(Boolean enabled)
Used to enable or disable logging, and other debug features. Defaults to BuildConfig.DEBUG.
Parameters:
enabled - Debug features (like logging) are enabled if true, disabled if false.

isLegacyTokenUpgradeSupported

 final static BooleanisLegacyTokenUpgradeSupported()
Indicates if the SDK should fallback and read the legacy token. This is turned off by default for performance.

setLegacyTokenUpgradeSupported

 final static UnitsetLegacyTokenUpgradeSupported(Boolean supported)
Setter for legacy token upgrade.
Parameters:
supported - True if upgrade should be supported.

getGraphApiVersion

 final static StringgetGraphApiVersion()
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.

setGraphApiVersion

 final static UnitsetGraphApiVersion(String graphApiVersion)
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.
Parameters:
graphApiVersion - the Graph API version, it should be of the form ServerProtocol.

isFullyInitialized

@Synchronized() final static BooleanisFullyInitialized()
Indicates whether the Facebook SDK has been fully initialized.
Facebook SDK won't work before fully initialized.

getFacebookDomain

 final static StringgetFacebookDomain()
Gets the base Facebook domain to use when making Web Requests; in production code this will always be "facebook.com".
This is required for PlatformDialogs which always need to use facebook.com

getInstagramDomain

 final static StringgetInstagramDomain()
Gets the base Instagram domain to use when making Web Requests; in production code this will always be "instagram.com".

setFacebookDomain

 final static UnitsetFacebookDomain(String facebookDomain)
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.
Updating this will also affect getGraphDomain calls. Setting "beta.facebook.com" will return beta.fb.gg if using the gaming domain for example.
Parameters:
facebookDomain - the base domain to use instead of "facebook.

sdkInitialize

@Deprecated(message = )@Synchronized() final static UnitsdkInitialize(Context applicationContext, Integer callbackRequestCodeOffset)
This function initializes the Facebook SDK. This function is called automatically on app start up if the proper entries are listed in the AndroidManifest, such as the facebook app id. This method can be called manually if needed. The behavior of Facebook SDK functions are undetermined if this function is not called. It should be called as early as possible. As part of SDK initialization basic auto logging of app events will occur, this can be controlled via 'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting
Parameters:
applicationContext - The application context
callbackRequestCodeOffset - The request code offset that Facebook activities will be called with.

sdkInitialize

@Deprecated(message = )@Synchronized() final static UnitsdkInitialize(Context applicationContext, Integer callbackRequestCodeOffset, FacebookSdk.InitializeCallback callback)
This function initializes the Facebook SDK. This function is called automatically on app start up if the proper entries are listed in the AndroidManifest, such as the facebook app id. This method can be called manually if needed. The behavior of Facebook SDK functions are undetermined if this function is not called. It should be called as early as possible. As part of SDK initialization basic auto logging of app events will occur, this can be controlled via 'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting
Parameters:
applicationContext - The application context
callbackRequestCodeOffset - The request code offset that Facebook activities will be called with.
callback - A callback called when initialize finishes.

sdkInitialize

@Deprecated(message = )@Synchronized() final static UnitsdkInitialize(Context applicationContext)
This function initializes the Facebook SDK. This function is called automatically on app start up if the proper entries are listed in the AndroidManifest, such as the facebook app id. This method can be called manually if needed. The behavior of Facebook SDK functions are undetermined if this function is not called. It should be called as early as possible. As part of SDK initialization basic auto logging of app events will occur, this can be controlled via 'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting
Parameters:
applicationContext - The application context @Deprecated sdkInitialize and AppEventsLogger.activateApp are called automatically on application start.

sdkInitialize

@Deprecated(message = )@Synchronized() final static UnitsdkInitialize(Context applicationContext, FacebookSdk.InitializeCallback callback)
This function initializes the Facebook SDK. This function is called automatically on app start up if the proper entries are listed in the AndroidManifest, such as the facebook app id. This method can bee called manually if needed. The behavior of Facebook SDK functions are undetermined if this function is not called. It should be called as early as possible. As part of SDK initialization basic auto logging of app events will occur, this can be controlled via 'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting
Parameters:
applicationContext - The application context
callback - A callback called when initialize finishes.

isInitialized

 final static BooleanisInitialized()
Indicates whether the Facebook SDK has been initialized.

fullyInitialize

 final static UnitfullyInitialize()
Mark Facebook SDK fully initialized to make it works as expected.

getLoggingBehaviors

 final static Set<LoggingBehavior> 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.

addLoggingBehavior

 final static UnitaddLoggingBehavior(LoggingBehavior behavior)
Certain logging behaviors are available for debugging beyond those that should be enabled in production.
Enables a particular extended logging in the SDK.
Parameters:
behavior - The LoggingBehavior to enable

removeLoggingBehavior

 final static UnitremoveLoggingBehavior(LoggingBehavior behavior)
Certain logging behaviors are available for debugging beyond those that should be enabled in production.
Disables a particular extended logging behavior in the SDK.
Parameters:
behavior - The LoggingBehavior to disable

clearLoggingBehaviors

 final static UnitclearLoggingBehaviors()
Certain logging behaviors are available for debugging beyond those that should be enabled in production.
Disables all extended logging behaviors.

isLoggingBehaviorEnabled

 final static BooleanisLoggingBehaviorEnabled(LoggingBehavior behavior)
Certain logging behaviors are available for debugging beyond those that should be enabled in production.
Checks if a particular extended logging behavior is enabled.
Parameters:
behavior - The LoggingBehavior to check

getGraphDomain

 final static StringgetGraphDomain()
Gets the base Facebook domain to use when making Graph API requests; in production code this will normally be "facebook.com". However certain Access Tokens are meant to be used with other domains. Currently gaming -> fb.gg
This checks the current Access Token (if any) and returns the correct domain to use.

getApplicationContext

 final static ContextgetApplicationContext()
The getter for the context of the current application.

publishInstallAsync

 final static UnitpublishInstallAsync(Context context, String applicationId)
This method is public in order to be used by app events, please don't use directly.
Parameters:
context - The application context.
applicationId - The application id.

getSdkVersion

 final static StringgetSdkVersion()
Returns the current version of the Facebook SDK for Android as a string.

getLimitEventAndDataUsage

 final static BooleangetLimitEventAndDataUsage(Context 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.
Parameters:
context - Used to read the value.

setLimitEventAndDataUsage

 final static UnitsetLimitEventAndDataUsage(Context context, Boolean limitEventUsage)
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.
Parameters:
context - Used to persist this value across app runs.

getApplicationSignature

 final static StringgetApplicationSignature(Context context)
Internal call please don't use directly.
Parameters:
context - The application context.

getApplicationId

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

setApplicationId

 final static UnitsetApplicationId(String applicationId)
Sets the Facebook application ID for the current app.
Parameters:
applicationId - the application ID

getApplicationName

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

setApplicationName

 final static UnitsetApplicationName(String applicationName)
Sets the Facebook application name for the current app.
Parameters:
applicationName - the application name

getClientToken

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

setClientToken

 final static UnitsetClientToken(String clientToken)
Sets the Facebook client token for the current app.
Parameters:
clientToken - the client token

getAutoInitEnabled

 final static BooleangetAutoInitEnabled()

setAutoInitEnabled

 final static UnitsetAutoInitEnabled(Boolean flag)
Sets the auto init SDK flag for the application
Parameters:
flag - true or falseWhen flag is false, SDK is not fully initialized.

getAutoLogAppEventsEnabled

 final static BooleangetAutoLogAppEventsEnabled()

setAutoLogAppEventsEnabled

 final static UnitsetAutoLogAppEventsEnabled(Boolean flag)
Sets the auto logging events flag for the application com.facebook.appevents.AppEventsLogger
Parameters:
flag - true or falseWhen flag is false, events will not be logged, see com.facebook.appevents.internal.AutomaticAnalyticsLogger

getCodelessDebugLogEnabled

 final static BooleangetCodelessDebugLogEnabled()

getCodelessSetupEnabled

 final static BooleangetCodelessSetupEnabled()

getAdvertiserIDCollectionEnabled

 final static BooleangetAdvertiserIDCollectionEnabled()

setAdvertiserIDCollectionEnabled

 final static UnitsetAdvertiserIDCollectionEnabled(Boolean flag)
Sets the advertiserID collection flag for the application
Parameters:
flag - true or false

setCodelessDebugLogEnabled

 final static UnitsetCodelessDebugLogEnabled(Boolean flag)
Sets the codeless debug flag for the application
Parameters:
flag - true or false

getMonitorEnabled

 final static BooleangetMonitorEnabled()
Gets the flag of Monitor Feature

setMonitorEnabled

 final static UnitsetMonitorEnabled(Boolean flag)
Sets the monitor flag for the application
Parameters:
flag - true or false

setDataProcessingOptions

 final static UnitsetDataProcessingOptions(Array<String> options)
Sets data processing options

setDataProcessingOptions

 final static UnitsetDataProcessingOptions(Array<String> options, Integer country, Integer state)
Sets data processing options

getCacheDir

 final static FilegetCacheDir()
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.

setCacheDir

 final static UnitsetCacheDir(File cacheDir)
Sets the cache directory to use for caching responses, etc.
Parameters:
cacheDir - the cache directory

getCallbackRequestCodeOffset

 final static IntegergetCallbackRequestCodeOffset()
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.

isFacebookRequestCode

 final static BooleanisFacebookRequestCode(Integer requestCode)
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.
Parameters:
requestCode - the request code to check.

getCALLBACK_OFFSET_CHANGED_AFTER_INIT

 final StringgetCALLBACK_OFFSET_CHANGED_AFTER_INIT()

getCALLBACK_OFFSET_NEGATIVE

 final StringgetCALLBACK_OFFSET_NEGATIVE()

getAPP_EVENT_PREFERENCES

 final StringgetAPP_EVENT_PREFERENCES()
The key for AppEvent perfernece setting.

getDATA_PROCESSING_OPTIONS_PREFERENCES

 final StringgetDATA_PROCESSING_OPTIONS_PREFERENCES()
The key for the data processing options preference setting.

getAPPLICATION_ID_PROPERTY

 final StringgetAPPLICATION_ID_PROPERTY()
The key for the application ID in the Android manifest.

getAPPLICATION_NAME_PROPERTY

 final StringgetAPPLICATION_NAME_PROPERTY()
The key for the application name in the Android manifest.

getCLIENT_TOKEN_PROPERTY

 final StringgetCLIENT_TOKEN_PROPERTY()
The key for the client token in the Android manifest.

getWEB_DIALOG_THEME

 final StringgetWEB_DIALOG_THEME()
The key for the web dialog theme in the Android manifest.

getAUTO_INIT_ENABLED_PROPERTY

 final StringgetAUTO_INIT_ENABLED_PROPERTY()
The key for the auto init SDK in the Android manifest.

getAUTO_LOG_APP_EVENTS_ENABLED_PROPERTY

 final StringgetAUTO_LOG_APP_EVENTS_ENABLED_PROPERTY()
The key for the auto logging app events in the Android manifest.

getCODELESS_DEBUG_LOG_ENABLED_PROPERTY

 final StringgetCODELESS_DEBUG_LOG_ENABLED_PROPERTY()
The key for the auto log codeless in the Android manifest.

getADVERTISER_ID_COLLECTION_ENABLED_PROPERTY

 final StringgetADVERTISER_ID_COLLECTION_ENABLED_PROPERTY()
The key for the advertiserID collection in the Android manifest.

getCALLBACK_OFFSET_PROPERTY

 final StringgetCALLBACK_OFFSET_PROPERTY()
The key for the callback off set in the Android manifest.

getMONITOR_ENABLED_PROPERTY

 final StringgetMONITOR_ENABLED_PROPERTY()
The key for the monitor enable in the Android manifest.

getDATA_PROCESSION_OPTIONS

 final StringgetDATA_PROCESSION_OPTIONS()
The key for modes in data processing options.

getDATA_PROCESSION_OPTIONS_COUNTRY

 final StringgetDATA_PROCESSION_OPTIONS_COUNTRY()
The key for country in data processing options.

getDATA_PROCESSION_OPTIONS_STATE

 final StringgetDATA_PROCESSION_OPTIONS_STATE()
The key for state in data processing options.

getHasCustomTabsPrefetching

 final BooleangetHasCustomTabsPrefetching()

setHasCustomTabsPrefetching

 final UnitsetHasCustomTabsPrefetching(@JvmField() Boolean hasCustomTabsPrefetching)

getIgnoreAppSwitchToLoggedOut

 final BooleangetIgnoreAppSwitchToLoggedOut()

setIgnoreAppSwitchToLoggedOut

 final UnitsetIgnoreAppSwitchToLoggedOut(@JvmField() Boolean ignoreAppSwitchToLoggedOut)

getBypassAppSwitch

 final BooleangetBypassAppSwitch()

setBypassAppSwitch

 final UnitsetBypassAppSwitch(@JvmField() Boolean bypassAppSwitch)

getINSTAGRAM

 final StringgetINSTAGRAM()

getGAMING

 final StringgetGAMING()

getFACEBOOK_COM

 final StringgetFACEBOOK_COM()

getFB_GG

 final StringgetFB_GG()

getINSTAGRAM_COM

 final StringgetINSTAGRAM_COM()