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)
Параметр | Описание |
---|---|
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)
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)
Параметр | Описание |
---|---|
applicationContext | The application context |
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
facebookDomain | The base domain to use instead of "facebook.com" |
getApplicationContext()
The getter for the context of the current application.
public static Context getApplicationContext()
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)
Параметр | Описание |
---|---|
context | The application context. |
applicationId | The application id. |
getAttributionId(ContentResolver)
Returns the current attribution id from the facebook app.
public static String getAttributionId(ContentResolver contentResolver)
Параметр | Описание |
---|---|
contentResolver |
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
clientToken | The 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()
setCacheDir(File)
Sets the cache directory to use for caching responses, etc.
public static void setCacheDir(File cacheDir)
Параметр | Описание |
---|---|
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)
Параметр | Описание |
---|---|
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