public final class FacebookSdk
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
FacebookSdk.GraphRequestCreator
Abstraction for better testability.
|
static interface |
FacebookSdk.InitializeCallback
Callback passed to the sdkInitialize function.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ADVERTISER_ID_COLLECTION_ENABLED_PROPERTY
The key for the advertiserID collection in the Android manifest.
|
static java.lang.String |
APP_EVENT_PREFERENCES
The key for AppEvent perfernece setting.
|
static java.lang.String |
APPLICATION_ID_PROPERTY
The key for the application ID in the Android manifest.
|
static java.lang.String |
APPLICATION_NAME_PROPERTY
The key for the application name in the Android manifest.
|
static java.lang.String |
AUTO_INIT_ENABLED_PROPERTY
The key for the auto init SDK in the Android manifest.
|
static java.lang.String |
AUTO_LOG_APP_EVENTS_ENABLED_PROPERTY
The key for the auto logging app events in the Android manifest.
|
static java.lang.String |
CALLBACK_OFFSET_PROPERTY
The key for the callback off set in the Android manifest.
|
static java.lang.String |
CLIENT_TOKEN_PROPERTY
The key for the client token in the Android manifest.
|
static java.lang.String |
CODELESS_DEBUG_LOG_ENABLED_PROPERTY
The key for the auto log codeless in the Android manifest.
|
static java.lang.String |
DATA_PROCESSING_OPTIONS_PREFERENCES
The key for the data processing options preference setting.
|
static java.lang.String |
DATA_PROCESSION_OPTIONS
The key for modes in data processing options.
|
static java.lang.String |
DATA_PROCESSION_OPTIONS_COUNTRY
The key for country in data processing options.
|
static java.lang.String |
DATA_PROCESSION_OPTIONS_STATE
The key for state in data processing options.
|
static boolean |
hasCustomTabsPrefetching |
static boolean |
ignoreAppSwitchToLoggedOut |
static java.lang.String |
MONITOR_ENABLED_PROPERTY
The key for the monitor enable in the Android manifest.
|
static java.lang.String |
WEB_DIALOG_THEME
The key for the web dialog theme in the Android manifest.
|
| Constructor and Description |
|---|
FacebookSdk() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addLoggingBehavior(LoggingBehavior behavior)
Certain logging behaviors are available for debugging beyond those that should be enabled in
production.
|
static void |
clearLoggingBehaviors()
Certain logging behaviors are available for debugging beyond those that should be enabled in
production.
|
static void |
fullyInitialize()
Mark Facebook SDK fully intialized to make it works as expected.
|
static boolean |
getAdvertiserIDCollectionEnabled() |
static android.content.Context |
getApplicationContext()
The getter for the context of the current application.
|
static java.lang.String |
getApplicationId()
Gets the Facebook application ID for the current app.
|
static java.lang.String |
getApplicationName()
Gets the Facebook application name of the current app.
|
static java.lang.String |
getApplicationSignature(android.content.Context context)
Internal call please don't use directly.
|
static boolean |
getAutoInitEnabled() |
static boolean |
getAutoLogAppEventsEnabled()
Gets the flag used by
AppEventsLogger |
static java.io.File |
getCacheDir()
Gets the cache directory to use for caching responses, etc.
|
static int |
getCallbackRequestCodeOffset()
Getter for the callback request code offset.
|
static java.lang.String |
getClientToken()
Gets the client token for the current app.
|
static boolean |
getCodelessDebugLogEnabled() |
static boolean |
getCodelessSetupEnabled() |
static java.util.concurrent.Executor |
getExecutor()
Returns the Executor used by the SDK for non-AsyncTask background work.
|
static java.lang.String |
getFacebookDomain()
Gets the base Facebook domain to use when making Web Requests; in production code this will
always be "facebook.com".
|
static java.lang.String |
getGraphApiVersion()
Returns the Graph API version to use when making Graph requests.
|
static java.lang.String |
getGraphDomain()
Gets the base Facebook domain to use when making Graph API requests; in production code this
will normally be "facebook.com".
|
static boolean |
getLimitEventAndDataUsage(android.content.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.
|
static java.util.Set<LoggingBehavior> |
getLoggingBehaviors()
Certain logging behaviors are available for debugging beyond those that should be enabled in
production.
|
static boolean |
getMonitorEnabled()
Gets the flag of Monitor Feature
|
static long |
getOnProgressThreshold()
Gets the threshold used to report progress on requests.
|
static java.lang.String |
getSdkVersion()
Returns the current version of the Facebook SDK for Android as a string.
|
static boolean |
isDebugEnabled()
Indicates if we are in debug mode.
|
static boolean |
isFacebookRequestCode(int requestCode)
Returns true if the request code is within the range used by Facebook SDK requests.
|
static boolean |
isFullyInitialized()
Indicates whether the Facebook SDK has been fully initialized.
|
static boolean |
isInitialized()
Indicates whether the Facebook SDK has been initialized.
|
static boolean |
isLegacyTokenUpgradeSupported()
Indicates if the SDK should fallback and read the legacy token.
|
static boolean |
isLoggingBehaviorEnabled(LoggingBehavior behavior)
Certain logging behaviors are available for debugging beyond those that should be enabled in
production.
|
static void |
publishInstallAsync(android.content.Context context,
java.lang.String applicationId)
This method is public in order to be used by app events, please don't use directly.
|
static void |
removeLoggingBehavior(LoggingBehavior behavior)
Certain logging behaviors are available for debugging beyond those that should be enabled in
production.
|
static void |
sdkInitialize(android.content.Context applicationContext)
Deprecated.
|
static void |
sdkInitialize(android.content.Context applicationContext,
FacebookSdk.InitializeCallback callback)
Deprecated.
|
static void |
sdkInitialize(android.content.Context applicationContext,
int callbackRequestCodeOffset)
Deprecated.
|
static void |
sdkInitialize(android.content.Context applicationContext,
int callbackRequestCodeOffset,
FacebookSdk.InitializeCallback callback)
Deprecated.
|
static void |
setAdvertiserIDCollectionEnabled(boolean flag)
Sets the advertiserID collection flag for the application
|
static void |
setApplicationId(java.lang.String applicationId)
Sets the Facebook application ID for the current app.
|
static void |
setApplicationName(java.lang.String applicationName)
Sets the Facebook application name for the current app.
|
static void |
setAutoInitEnabled(boolean flag)
Sets the auto init SDK flag for the application
|
static void |
setAutoLogAppEventsEnabled(boolean flag)
Sets the auto logging events flag for the application
AppEventsLogger |
static void |
setCacheDir(java.io.File cacheDir)
Sets the cache directory to use for caching responses, etc.
|
static void |
setClientToken(java.lang.String clientToken)
Sets the Facebook client token for the current app.
|
static void |
setCodelessDebugLogEnabled(boolean flag)
Sets the codeless debug flag for the application
|
static void |
setDataProcessingOptions(java.lang.String[] options)
Sets data processing options
|
static void |
setDataProcessingOptions(java.lang.String[] options,
int country,
int state)
Sets data processing options
|
static void |
setExecutor(java.util.concurrent.Executor executor)
Sets the Executor used by the SDK for non-AsyncTask background work.
|
static void |
setFacebookDomain(java.lang.String facebookDomain)
Sets the base Facebook domain to use when making Web requests.
|
static void |
setGraphApiVersion(java.lang.String graphApiVersion)
Sets the Graph API version to use when making Graph requests.
|
static void |
setGraphRequestCreator(FacebookSdk.GraphRequestCreator graphRequestCreator) |
static void |
setIsDebugEnabled(boolean enabled)
Used to enable or disable logging, and other debug features.
|
static void |
setLegacyTokenUpgradeSupported(boolean supported)
Setter for legacy token upgrade.
|
static void |
setLimitEventAndDataUsage(android.content.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.
|
static void |
setMonitorEnabled(boolean flag)
Sets the monitor flag for the application
|
static void |
setOnProgressThreshold(long threshold)
Sets the threshold used to report progress on requests.
|
public static boolean hasCustomTabsPrefetching
public static boolean ignoreAppSwitchToLoggedOut
public static final java.lang.String APP_EVENT_PREFERENCES
public static final java.lang.String DATA_PROCESSING_OPTIONS_PREFERENCES
public static final java.lang.String APPLICATION_ID_PROPERTY
public static final java.lang.String APPLICATION_NAME_PROPERTY
public static final java.lang.String CLIENT_TOKEN_PROPERTY
public static final java.lang.String WEB_DIALOG_THEME
public static final java.lang.String AUTO_INIT_ENABLED_PROPERTY
public static final java.lang.String AUTO_LOG_APP_EVENTS_ENABLED_PROPERTY
public static final java.lang.String CODELESS_DEBUG_LOG_ENABLED_PROPERTY
public static final java.lang.String ADVERTISER_ID_COLLECTION_ENABLED_PROPERTY
public static final java.lang.String CALLBACK_OFFSET_PROPERTY
public static final java.lang.String MONITOR_ENABLED_PROPERTY
public static final java.lang.String DATA_PROCESSION_OPTIONS
public static final java.lang.String DATA_PROCESSION_OPTIONS_COUNTRY
public static final java.lang.String DATA_PROCESSION_OPTIONS_STATE
@Deprecated
public static void sdkInitialize(android.content.Context applicationContext,
int callbackRequestCodeOffset)
applicationContext - The application contextcallbackRequestCodeOffset - 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. @Deprecated sdkInitialize(Context) and AppEventsLogger.activateApp(Application) are called automatically on application start.
Automatic event logging from 'activateApp' can be controlled via the
'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting. The callbackRequestCodeOffset
can be set in the AndroidManifest as a meta data entry with the name CALLBACK_OFFSET_PROPERTY.@Deprecated
public static void sdkInitialize(android.content.Context applicationContext,
int callbackRequestCodeOffset,
FacebookSdk.InitializeCallback callback)
applicationContext - The application contextcallbackRequestCodeOffset - 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. @Deprecated sdkInitialize(Context) and AppEventsLogger.activateApp(Application) are called automatically on application start.
Automatic event logging from 'activateApp' can be controlled via the
'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting. The callbackRequestCodeOffset
can be set in the AndroidManifest as a meta data entry with the name CALLBACK_OFFSET_PROPERTY.@Deprecated public static void sdkInitialize(android.content.Context applicationContext)
applicationContext - The application context @Deprecated sdkInitialize(Context)
and AppEventsLogger.activateApp(Application) are called automatically on
application start. Automatic event logging from 'activateApp' can be controlled via the
'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting.@Deprecated
public static void sdkInitialize(android.content.Context applicationContext,
FacebookSdk.InitializeCallback callback)
applicationContext - The application contextcallback - A callback called when initialize finishes. This will be called even if the sdk
is already initialized. @Deprecated sdkInitialize(Context) and AppEventsLogger.activateApp(Application) are called automatically on application start.
Automatic event logging from 'activateApp' can be controlled via the
'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting.public static boolean isInitialized()
public static boolean isFullyInitialized()
Facebook SDK won't work before fully initialized.
public static void fullyInitialize()
public static java.util.Set<LoggingBehavior> getLoggingBehaviors()
Returns the types of extended logging that are currently enabled.
public static void addLoggingBehavior(LoggingBehavior behavior)
Enables a particular extended logging in the SDK.
behavior - The LoggingBehavior to enablepublic static void removeLoggingBehavior(LoggingBehavior behavior)
Disables a particular extended logging behavior in the SDK.
behavior - The LoggingBehavior to disablepublic static void clearLoggingBehaviors()
Disables all extended logging behaviors.
public static boolean isLoggingBehaviorEnabled(LoggingBehavior behavior)
Checks if a particular extended logging behavior is enabled.
behavior - The LoggingBehavior to checkpublic static boolean isDebugEnabled()
public static void setIsDebugEnabled(boolean enabled)
enabled - Debug features (like logging) are enabled if true, disabled if false.public static boolean isLegacyTokenUpgradeSupported()
public static void setLegacyTokenUpgradeSupported(boolean supported)
supported - True if upgrade should be supported.public static java.util.concurrent.Executor getExecutor()
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 void setExecutor(java.util.concurrent.Executor executor)
executor - the Executor to use; must not be null.public static java.lang.String getFacebookDomain()
This is required for PlatformDialogs which always need to use facebook.com
public static java.lang.String getGraphDomain()
This checks the current Access Token (if any) and returns the correct domain to use.
public static void setFacebookDomain(java.lang.String facebookDomain)
Updating this will also affect getGraphDomain calls. Setting "beta.facebook.com" will return beta.fb.gg if using the gaming domain for example.
facebookDomain - the base domain to use instead of "facebook.com"public static android.content.Context getApplicationContext()
public static void setGraphApiVersion(java.lang.String graphApiVersion)
graphApiVersion - the Graph API version, it should be of the form
ServerProtocol.getDefaultAPIVersion()public static java.lang.String getGraphApiVersion()
public static void publishInstallAsync(android.content.Context context,
java.lang.String applicationId)
context - The application context.applicationId - The application id.public static java.lang.String getSdkVersion()
public static boolean getLimitEventAndDataUsage(android.content.Context context)
context - Used to read the value.public static void setLimitEventAndDataUsage(android.content.Context context,
boolean limitEventUsage)
context - Used to persist this value across app runs.public static long getOnProgressThreshold()
public static void setOnProgressThreshold(long threshold)
threshold - The number of bytes progressed to force a callback.public static java.lang.String getApplicationSignature(android.content.Context context)
context - The application context.public static java.lang.String getApplicationId()
public static void setApplicationId(java.lang.String applicationId)
applicationId - the application ID@Nullable public static java.lang.String getApplicationName()
public static void setApplicationName(java.lang.String applicationName)
applicationName - the application namepublic static java.lang.String getClientToken()
public static void setClientToken(java.lang.String clientToken)
clientToken - the client tokenpublic static boolean getAutoInitEnabled()
public static void setAutoInitEnabled(boolean flag)
flag - true or false
When flag is false, SDK is not fully initialized.
public static boolean getAutoLogAppEventsEnabled()
AppEventsLoggerpublic static void setAutoLogAppEventsEnabled(boolean flag)
AppEventsLoggerflag - true or false
When flag is false, events will not be logged, see AutomaticAnalyticsLogger
public static boolean getCodelessDebugLogEnabled()
public static boolean getCodelessSetupEnabled()
public static void setAdvertiserIDCollectionEnabled(boolean flag)
flag - true or falsepublic static boolean getAdvertiserIDCollectionEnabled()
public static void setCodelessDebugLogEnabled(boolean flag)
flag - true or falsepublic static boolean getMonitorEnabled()
public static void setMonitorEnabled(boolean flag)
flag - true or falsepublic static void setDataProcessingOptions(java.lang.String[] options)
public static void setDataProcessingOptions(java.lang.String[] options,
int country,
int state)
public static java.io.File getCacheDir()
public static void setCacheDir(java.io.File cacheDir)
cacheDir - the cache directorypublic static int getCallbackRequestCodeOffset()
public static boolean isFacebookRequestCode(int requestCode)
requestCode - the request code to check.public static void setGraphRequestCreator(FacebookSdk.GraphRequestCreator graphRequestCreator)