bfgManager Class
Initialize the Big Fish SDK. More...
Classes | |
class | PolicyControlConstants |
The policy control constant values used for toggling policy controlled features like 3rd-party advertising. More... | |
Public Member Functions | |
abstract boolean | checkForInternetConnection (boolean showStore) |
Returns a boolean indicating whether the device can access the Internet. More... | |
abstract long | currentPlaytime () |
Get the total elapsed play time of game play from first launch. More... | |
Activity | getSafeParentViewController () |
Retrieves the root Activity (must exist) More... | |
abstract Activity | getTopMostViewController () |
Retrieves the top-most Activity instance. More... | |
abstract boolean | isInitialLaunch () |
Returns whether or not this is the initial launch of the application by checking the current session count. More... | |
abstract boolean | navigateToURL (@NonNull String urlString) |
Launches the appropriate activity for the given URL. More... | |
abstract void | setAttributionUserID (String userID) |
Set the attribution user ID (if this option is also enabled in bfg_config) More... | |
abstract void | setParentViewController (Activity parent) |
Set the current parent view controller. More... | |
abstract void | setSessionEndEvent (@NonNull String strValue) |
Accessor for sessionEndEvent member variable. More... | |
abstract void | setUserID (long userID) |
Set the current user ID. More... | |
abstract void | showAlert (boolean showStore) |
Shows the no network connection AlertDialog with/without store details. More... | |
abstract void | showPrivacy () |
abstract void | showSupport () |
Launches the Help Center Activity. More... | |
abstract void | showTerms () |
abstract void | showView (@NonNull Class<?> theClass) |
Starts the supplied Activity by calling the startActivity() method of the top-most Activity. More... | |
abstract void | showWebBrowser (@NonNull String strLink) |
abstract long | userID () |
Get current user ID. More... | |
Static Public Member Functions | |
static boolean | activitiesStateResumed () |
Is the SDK is in a resumed state? true/false. | |
static void | activityCreated (@NonNull final Activity activity) |
Notifies the BFG SDK manager that an activity has been created so it can maintain a stack of the activities along with their classes. More... | |
static void | activityFinished (@NonNull final Activity activity) |
Notifies the BFG SDK manager that an activity within this application is about to finish. More... | |
static void | activityFinished (@NonNull final String activityClassName) |
Notifies the BFG SDK manager that an activity within this application is about to finish. More... | |
static void | activityStarted (@NonNull final String activity) |
Notifies the BFG SDK manager that an activity within this application has been launched. More... | |
static void | addPolicyListener (@NonNull final bfgPolicyListener policyListener) |
Registers a listener for policy consent events. More... | |
static boolean | didAcceptPolicyControl (final @NonNull String policyControl) |
Determines if a given policy control was accepted. More... | |
static Activity | getParentViewController () |
Retrieves the root Activity, if any. More... | |
static void | hideSoftKeyboard (@NonNull final Activity activity) |
Hides the soft-keyboard. More... | |
static synchronized void | initializeWithActivity (@NonNull final Activity controller, @Nullable final Bundle savedInstanceState) |
Perform startup initialization setup with the supplied root activity. More... | |
static boolean | isInitialized () |
Determine if SDK is initialized yet. More... | |
static void | pause (@NonNull final Activity activityPaused) |
Called by Activity.onPause() to receive notification that the Activity has been hidden (no longer in the foreground). More... | |
static void | pauseApp () |
Request pause of the game (app) | |
static void | post (@NonNull Runnable r) |
Post a runnable to be invoked on the UI thread. More... | |
static void | postDelayed (@NonNull final Runnable r, final int delayMS) |
Post a runnable to be invoked on the UI thread after a delay. More... | |
static void | postRunnable (@NonNull Runnable r) |
Posts the supplied runnable to the UI thread queue, or invokes the runnable immediately if called on the UI thread. More... | |
static boolean | removeDuplicateActivity (@NonNull final Activity activity) |
Was an orphaned copy of this activity removed to make room for the specified activity. More... | |
static void | removePolicyListener (@NonNull final bfgPolicyListener policyListener) |
Removes a listener for policy consent events. More... | |
static void | resume (@NonNull final Activity activityResumed) |
Called by Activity.onResume() to receive notification that the Activity is now about to be presented (brought to the foreground). More... | |
static void | resumeApp () |
Request resume of previously paused game (app) | |
static bfgManager | sharedInstance () |
Gets a shared instance of the bfgManager singleton that is guaranteed to not be null. More... | |
static void | showSoftKeyboard (@NonNull final Activity activity) |
Shows the soft-keyboard. More... | |
static void | start (@NonNull final Activity activityStarted) |
static void | stop (@NonNull final Activity activityStopped) |
Called by Activity.onResume() to receive notification that the Activity is now about to be presented (brought to the foreground). More... | |
static String | transformDeepLinkToRetailLink (@NonNull final Uri uri) |
Tries to re-map deep links to retail website links. More... | |
Static Public Attributes | |
static final String | BFG_NOTIFICATION_COLD_START = "BFG_NOTIFICATION_COLD_START" |
Sent on a Cold Start. | |
static final String | BFG_NOTIFICATION_WARM_START = "BFG_NOTIFICATION_WARM_START" |
Sent on a Warm Start. | |
static final String | BFGPROMODASHBOARD_NOTIFICATION_COLDSTART = "BFGPROMODASHBOARD_NOTIFICATION_CONTINUE" |
static final String | BFGPROMODASHBOARD_NOTIFICATION_WARMSTART = "BFGPROMODASHBOARD_NOTIFICATION_APPLICATION_RESUMED" |
Protected Attributes | |
ConcurrentHashMap< Activity, Integer > | mActivityStates = new ConcurrentHashMap<>() |
Stack of 'tracked' activity classes so we know when the dashboard should not be shown. | |
Detailed Description
Initialize the Big Fish SDK. You should initialize the bfgManager when your application finishes launching with your main Activity.You should NOT call into BFG SDK methods until you have called
com.bigfishgames.bfglib.bfgManager#initializeWithActivity(Activity, Bundle)
The bfgManager requires notification of several Activity lifecycle events, so the following code must be added to your root or main Activity:// The main activity must add calls to these bfgManager methods to ensure
// proper initialization and shutdown.
publicvoid onCreate(Bundle savedInstanceState) {
...
super.onCreate(savedInstanceState);
...
...
}
publicvoid onResume() {
...
super.onResume();
...
...
}
publicvoid onPause() {
...
bfgManager.pause(this);
...
super.onPause();
...
}
publicvoid onDestroy() {
...
bfgManager.destroy();
...
super.onDestroy();
...
}
static void activityCreated(@NonNull final Activity activity)
Notifies the BFG SDK manager that an activity has been created so it can maintain a stack of the acti...
Definition: bfgManager.java:439
static void resume(@NonNull final Activity activityResumed)
Called by Activity.onResume() to receive notification that the Activity is now about to be presented ...
Definition: bfgManager.java:641
static synchronized void initializeWithActivity(@NonNull final Activity controller, @Nullable final Bundle savedInstanceState)
Perform startup initialization setup with the supplied root activity.
Definition: bfgManager.java:342
// All other activities must add these calls to the bfgManager in order to
// properly notify the SDK of activity lifecycle events.
publicvoid onCreate(Bundle savedInstanceState) {
...
super.onCreate(savedInstanceState);
...
...
}
publicvoid onResume() {
...
super.onResume();
...
...
}
publicvoid onPause() {
...
bfgManager.pause(this);
...
super.onPause();
...
}
publicvoid onBackPressed() {
...
super.onBackPressed();
...
// This must be called before the onStop and onDestroy methods are called
bfgManager.activityFinished(this);
...
}
publicvoid someOtherMethod() {
...
finish();
// This must be called before the onStop and onDestroy methods are called
bfgManager.activityFinished(this);
...
}
Member Function Documentation
◆ activityCreated()
| inlinestatic |
Notifies the BFG SDK manager that an activity has been created so it can maintain a stack of the activities along with their classes. This must be called in the onCreate() of tracked activities.
- Parameters
activityCreated Activity instance that was created.
◆ activityFinished() [1/2]
| inlinestatic |
Notifies the BFG SDK manager that an activity within this application is about to finish. Typically, this is called immediately after Activity.finish() is called, and is usually invoked by the activity itself.This method must not be called for any activities that are not owned by the application.
- Parameters
activityFinished Activity instance that will be stopped.
◆ activityFinished() [2/2]
| inlinestatic |
Notifies the BFG SDK manager that an activity within this application is about to finish. Typically, this is called immediately after Activity.finish() is called, and is usually invoked by the activity itself.This method must not be called for any activities that are not owned by the application.
- Parameters
activityClass Activity class that will be stopped.
◆ activityStarted()
| inlinestatic |
Notifies the BFG SDK manager that an activity within this application has been launched. This method must not be called for any activities that are not owned by the application.This is an internal BFG SDK method.
- Parameters
activityClass Activity class that was started.
◆ addPolicyListener()
| inlinestatic |
Registers a listener for policy consent events. See the
com.bigfishgames.bfglib.bfgGdpr.bfgPolicyListener
class for more information on the callbacks provided for this listener. This method must be invoked in the onStart event of every Activity in a game. The corresponding removePolicyListener method must be invoked in the onStop and onDestroy events of every Activity in a game.- Parameters
policyListener Listener to receive policy event callbacks
- Since
- 6.7
◆ checkForInternetConnection()
| abstract |
Returns a boolean indicating whether the device can access the Internet. For convenience, this method also displays a built-in alert dialog notifying the user that an Internet connection was not found. As such, this method must only be invoked on the UI thread. To check for the presence of an Internet connection on a non-UI thread, or if you do not wish to display the alert dialog, call the bfgConnectivity.connectivityForInternetConnection() method directly.
- Parameters
showStore Pass true if the alert view should identify the application store when no Internet connection is available. If this parameter is false, the alert view will show a generic offline error.
- Returns
- True if the device can access the Internet, false otherwise.
◆ currentPlaytime()
| abstract |
Get the total elapsed play time of game play from first launch.
- Returns
- Total elapsed play time in seconds.
◆ didAcceptPolicyControl()
| inlinestatic |
Determines if a given policy control was accepted.
- Parameters
policyControl The policy control name to check (See bfgManager.PolicyControlConstants
)
- Returns
- TRUE if the control specified by policyControl was accepted, otherwise FALSE.
- Since
- 6.7
◆ getParentViewController()
| inlinestatic |
Retrieves the root Activity, if any. The root activity will be the one that was supplied in the call to initializeWithActivity() or re-assigned by a call to setParentViewController(). If the caller is not sure if the SDK has been initialized, then it should call bfgManager.isInitialized() before assuming the result is non-null or check the result for null before using.
- Returns
- The root Activity or null if the SDK has not been initialized.
◆ getSafeParentViewController()
| inline |
Retrieves the root Activity (must exist) The root activity will be the one that was supplied in the call to initializeWithActivity() or re-assigned by a call to setParentViewController(). This method will throw an IllegalStateException if called before initializeWithActivity().
- Returns
- The non-null root Activity.
- Since
- 6.8
◆ getTopMostViewController()
| abstract |
Retrieves the top-most Activity instance. This method is used internally by the BFG SDK.
- Returns
- Top-most Activity or null.
◆ hideSoftKeyboard()
| inlinestatic |
Hides the soft-keyboard. Normally, activities do not need to explicitly call this method since the keyboard display is handled for normal lifecycle events. However, there may be times when explicitly closing the keyboard is required.
- Parameters
activity The Activity needing the keyboard closed.
- Since
- 6.3
◆ initializeWithActivity()
| inlinestatic |
Perform startup initialization setup with the supplied root activity. This is the activity to use when showing interstitials, for both startup and resume UI. This activity can be overridden using the setParentActivity method.
- Parameters
controller Root (parent view controller) activity. savedInstanceState The Bundle that was passed into the onCreate method of the calling Activity.
◆ isInitialized()
| inlinestatic |
Determine if SDK is initialized yet.
- Returns
- TRUE if SDK is initialized and ready for use
◆ isInitialLaunch()
| abstract |
Returns whether or not this is the initial launch of the application by checking the current session count. If it's less than 2, this is the initial launch.
- Returns
- True if this is the initial launch of the application, false otherwise.
◆ navigateToURL()
| abstract |
Launches the appropriate activity for the given URL. If the supplied URL scheme is "market" or "amzn", the bfgManager will attempt to launch the application that handles that uri scheme (e.g., Android Market/Google Play) via startActivityWithDataUri. Also, if it is a "link-share" link, it will be handled externally via startActivityWithDataUri. Also, if externalBrowser is true, it will be handled externally via startActivityWithDataUri.On the other hand, if the supplied URL scheme is anything other than "market" or "amzn", the activity will launch the in-game web browser to view web pages or product review pages.WARNING: If it is a link-share link that redirects to the "amzn" or "market" scheme and there are no activities that handle these, this will most likely result in "Page not available".
- Parameters
urlString URL to view.
◆ pause()
| inlinestatic |
Called by Activity.onPause() to receive notification that the Activity has been hidden (no longer in the foreground). The bfgManager uses the pause() and resume() methods to track activity switches and detect when the entire application has been suspended, or if the current activity was paused by another activity within the application.
- Parameters
activityPaused The instance of the activity that was just paused.
◆ post()
| inlinestatic |
Post a runnable to be invoked on the UI thread.
- Parameters
r Runnable whose run() method is to be invoked.
◆ postDelayed()
| inlinestatic |
Post a runnable to be invoked on the UI thread after a delay.
- Parameters
r Runnable whose run() method is to be invoked. delay Time in milliseconds to delay the call to the Runnable object's run() method.
◆ postRunnable()
| inlinestatic |
Posts the supplied runnable to the UI thread queue, or invokes the runnable immediately if called on the UI thread.
- Parameters
r Runnable whose run() method is to be invoked.
◆ removeDuplicateActivity()
| inlinestatic |
Was an orphaned copy of this activity removed to make room for the specified activity.
- Parameters
activity Activity (controller) to check whether it had an orphaned version on the activity stack.
- Returns
- TRUE if an orphaned instance of the activity was already on the stack when this activity was created.
◆ removePolicyListener()
| inlinestatic |
Removes a listener for policy consent events. This method must be invoked in the onStop and onDestroy events of every Activity in a game. The corresponding
addPolicyListener
method must be invoked in the onStart event of every Activity in a game.- Parameters
policyListener Listener to remove from policy event callbacks. This listener is assumed to have been used to add a listener using a prior call to addPolicyListener
and will be ignored otherwise.
- Since
- 6.7
◆ resume()
| inlinestatic |
Called by Activity.onResume() to receive notification that the Activity is now about to be presented (brought to the foreground). The bfgManager uses the pause() and resume() methods to track activity switches and detect when the entire application has been suspended, or if the current activity was paused by another activity within the application.
- Parameters
activityResumed The instance of the activity that was just resumed.
◆ setAttributionUserID()
| abstract |
Set the attribution user ID (if this option is also enabled in bfg_config)
- Parameters
userID User ID to set.
◆ setParentViewController()
| abstract |
Set the current parent view controller. This sets the view controller to use when showing interstitials for both launch (startup) and resume events in the UI. The parent view controller is initially set using the initializeWithActivity, but can be changed by calling this method if a different view should become the parent view for receiving GDN and interstitials. If you change your root Activity, you must call this method.
- Parameters
parent New parent view controller.
◆ setSessionEndEvent()
| abstract |
Accessor for sessionEndEvent member variable.
- Parameters
strValue Value describing the end event.
◆ setUserID()
| abstract |
Set the current user ID.
- Parameters
userID User ID to set.
◆ sharedInstance()
| inlinestatic |
Gets a shared instance of the bfgManager singleton that is guaranteed to not be null. It will throw an IllegalStateException if called before the SDK is initialized.
- Returns
- A non-null instance of bfgManager.
◆ showAlert()
| abstract |
Shows the no network connection AlertDialog with/without store details.
- Parameters
showStore Flag controlling the display of the store details in the dialog.
◆ showPrivacy()
| abstract |
Show the Privacy page using the in-game browser.
◆ showSoftKeyboard()
| inlinestatic |
Shows the soft-keyboard. Normally, activities do not need to explicitly call this method since the keyboard display is handled for normal lifecycle events. However, there may be times when explicitly opening the keyboard is required.
- Parameters
activity The Activity needing the keyboard shown.
- Since
- 6.3
◆ showSupport()
| abstract |
Launches the Help Center Activity. Requires that parentViewController is set.
◆ showTerms()
| abstract |
Show the Terms of Use page with the in-game browser.
◆ showView()
| abstract |
Starts the supplied Activity by calling the startActivity() method of the top-most Activity. The bfgManager uses this method, along with appropriate calls to other bfgManager methods, to track changes to the Activity stack.
- Parameters
theClass Activity class to start.
◆ showWebBrowser()
| abstract |
Show an in-game browser displaying startPage. This method must be called on the UI thread.
- Parameters
startPage URL whose content is to be displayed to the user.
◆ start()
| inlinestatic |
- Parameters
activityStarted
◆ stop()
| inlinestatic |
Called by Activity.onResume() to receive notification that the Activity is now about to be presented (brought to the foreground). The bfgManager uses the pause() and resume() methods to track activity switches and detect when the entire application has been suspended, or if the current activity was paused by another activity within the application.
- Parameters
activityStopped The instance of the activity that was just resumed.
◆ transformDeepLinkToRetailLink()
| inlinestatic |
Tries to re-map deep links to retail website links. The following re-mappings are supported for 'Google Play':1) market://details?id=<package_name> (scheme is 'market' and path contains 'details') maps to "https://play.google.com/store/apps/details?id=<package_name> 2) market://apps/collection/<collection_name> (scheme is 'market' and path contains 'collection') maps to "https://play.google.com/store/apps/collection/<collection_name>" NOTE: Although collections are a valid deep link, on many devices they only go to the store front. 3) market://search?q=pub:<publisher_name> (otherwise, if scheme is 'market', assume a generic search) market://search?q=<search_query>&c=apps maps to "https://play.google.com/store/search?q=<search_query>&c=apps"The following re-mappings are supported for 'Amazon Client':1) amzn://apps/android?<params> maps to https://www.amazon.com/gp/mas/dl/android?<params>
- Parameters
uri The deep linking URI to transform.
- Returns
- A String of the transformed deep link.
◆ userID()
| abstract |
Get current user ID.
- Returns
- Current user ID (0 if none).
Member Data Documentation
◆ BFGPROMODASHBOARD_NOTIFICATION_COLDSTART
| static |
- Deprecated:\n Use BFG_NOTIFICATION_COLD_START instead
◆ BFGPROMODASHBOARD_NOTIFICATION_WARMSTART
| static |
- Deprecated:\n Use BFG_NOTIFICATION_WARM_START instead