Package 

Object FacebookSdk


  • 
    public class FacebookSdk
    
                        

    This class allows some customization of Facebook SDK behavior.

    • Method Detail

      • getExecutor

         final static Executor 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.

      • setExecutor

         final static Unit setExecutor(Executor executor)

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

        Parameters:
        executor - the Executor to use; must not be null.
      • setOnProgressThreshold

         final static Unit setOnProgressThreshold(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.
      • setIsDebugEnabled

         final static Unit setIsDebugEnabled(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 Boolean isLegacyTokenUpgradeSupported()

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

      • getGraphApiVersion

         final static String 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.

      • setGraphApiVersion

         final static Unit setGraphApiVersion(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 Boolean isFullyInitialized()

        Indicates whether the Facebook SDK has been fully initialized.

        Facebook SDK won't work before fully initialized.

      • getFacebookDomain

         final static String getFacebookDomain()

        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

      • getFacebookGamingDomain

         final static String getFacebookGamingDomain()

        Gets the base Facebook gaming domain to use when making Web Requests; in production code this will always be "fb.gg".

        This is required for Custom Update Dialogs which always need to use fb.gg

      • getInstagramDomain

         final static String getInstagramDomain()

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

      • setFacebookDomain

         final static Unit setFacebookDomain(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 Unit sdkInitialize(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 Unit sdkInitialize(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 Unit sdkInitialize(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 Unit sdkInitialize(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 Boolean isInitialized()

        Indicates whether the Facebook SDK has been initialized.

      • fullyInitialize

         final static Unit fullyInitialize()

        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 Unit addLoggingBehavior(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 Unit removeLoggingBehavior(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 Unit clearLoggingBehaviors()

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

        Disables all extended logging behaviors.

      • isLoggingBehaviorEnabled

         final static Boolean isLoggingBehaviorEnabled(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 String getGraphDomain()

        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.

      • publishInstallAsync

         final static Unit publishInstallAsync(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 String getSdkVersion()

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

      • getLimitEventAndDataUsage

         final static Boolean getLimitEventAndDataUsage(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 Unit setLimitEventAndDataUsage(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.
      • getApplicationId

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

      • setApplicationId

         final static Unit setApplicationId(String applicationId)

        Sets the Facebook application ID for the current app.

        Parameters:
        applicationId - the application ID
      • getApplicationName

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

      • setApplicationName

         final static Unit setApplicationName(String applicationName)

        Sets the Facebook application name for the current app.

        Parameters:
        applicationName - the application name
      • getClientToken

         final static String getClientToken()

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

      • setClientToken

         final static Unit setClientToken(String clientToken)

        Sets the Facebook client token for the current app.

        Parameters:
        clientToken - the client token
      • setAutoInitEnabled

         final static Unit setAutoInitEnabled(Boolean flag)

        Sets the auto init SDK flag for the application

        Parameters:
        flag - true or falseWhen flag is false, SDK is not fully initialized.
      • setMonitorEnabled

         final static Unit setMonitorEnabled(Boolean flag)

        Sets the monitor flag for the application

        Parameters:
        flag - true or false
      • getCacheDir

         final static File 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.

      • setCacheDir

         final static Unit setCacheDir(File cacheDir)

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

        Parameters:
        cacheDir - the cache directory
      • getCallbackRequestCodeOffset

         final static Integer 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.

      • isFacebookRequestCode

         final static Boolean isFacebookRequestCode(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.