Skip to main content

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();
...
}
Initialize the Big Fish SDK.
Definition: bfgManager.java:126
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()

static void com.bigfishgames.bfglib.bfgManager.activityCreated (@NonNull final Activity activity)
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
activityCreatedActivity instance that was created.

◆ activityFinished() [1/2]

static void com.bigfishgames.bfglib.bfgManager.activityFinished (@NonNull final Activity activity)
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
activityFinishedActivity instance that will be stopped.

◆ activityFinished() [2/2]

static void com.bigfishgames.bfglib.bfgManager.activityFinished (@NonNull final String activityClassName)
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
activityClassActivity class that will be stopped.

◆ activityStarted()

static void com.bigfishgames.bfglib.bfgManager.activityStarted (@NonNull final String activity)
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
activityClassActivity class that was started.

◆ addPolicyListener()

static void com.bigfishgames.bfglib.bfgManager.addPolicyListener (@NonNull final bfgPolicyListener policyListener)
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
policyListenerListener to receive policy event callbacks
Since
6.7

◆ checkForInternetConnection()

abstract boolean com.bigfishgames.bfglib.bfgManager.checkForInternetConnection (boolean showStore)
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
showStorePass 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 long com.bigfishgames.bfglib.bfgManager.currentPlaytime ()
abstract
Get the total elapsed play time of game play from first launch.
Returns
Total elapsed play time in seconds.

◆ didAcceptPolicyControl()

static boolean com.bigfishgames.bfglib.bfgManager.didAcceptPolicyControl (final @NonNull String policyControl)
inlinestatic
Determines if a given policy control was accepted.
Parameters
policyControlThe policy control name to check (See bfgManager.PolicyControlConstants)
Returns
TRUE if the control specified by policyControl was accepted, otherwise FALSE.
Since
6.7

◆ getParentViewController()

static Activity com.bigfishgames.bfglib.bfgManager.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()

Activity com.bigfishgames.bfglib.bfgManager.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 Activity com.bigfishgames.bfglib.bfgManager.getTopMostViewController ()
abstract
Retrieves the top-most Activity instance. This method is used internally by the BFG SDK.
Returns
Top-most Activity or null.

◆ hideSoftKeyboard()

static void com.bigfishgames.bfglib.bfgManager.hideSoftKeyboard (@NonNull final Activity activity)
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
activityThe Activity needing the keyboard closed.
Since
6.3

◆ initializeWithActivity()

static synchronized void com.bigfishgames.bfglib.bfgManager.initializeWithActivity (@NonNull final Activity controller,
@Nullable final Bundle savedInstanceState 
)
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
controllerRoot (parent view controller) activity.
savedInstanceStateThe Bundle that was passed into the onCreate method of the calling Activity.

◆ isInitialized()

static boolean com.bigfishgames.bfglib.bfgManager.isInitialized ()
inlinestatic
Determine if SDK is initialized yet.
Returns
TRUE if SDK is initialized and ready for use

◆ isInitialLaunch()

abstract boolean com.bigfishgames.bfglib.bfgManager.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 boolean com.bigfishgames.bfglib.bfgManager.navigateToURL (@NonNull String urlString)
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
urlStringURL to view.

◆ pause()

static void com.bigfishgames.bfglib.bfgManager.pause (@NonNull final Activity activityPaused)
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
activityPausedThe instance of the activity that was just paused.

◆ post()

static void com.bigfishgames.bfglib.bfgManager.post (@NonNull Runnable r)
inlinestatic
Post a runnable to be invoked on the UI thread.
Parameters
rRunnable whose run() method is to be invoked.

◆ postDelayed()

static void com.bigfishgames.bfglib.bfgManager.postDelayed (@NonNull final Runnable r,
final int delayMS 
)
inlinestatic
Post a runnable to be invoked on the UI thread after a delay.
Parameters
rRunnable whose run() method is to be invoked.
delayTime in milliseconds to delay the call to the Runnable object's run() method.

◆ postRunnable()

static void com.bigfishgames.bfglib.bfgManager.postRunnable (@NonNull Runnable r)
inlinestatic
Posts the supplied runnable to the UI thread queue, or invokes the runnable immediately if called on the UI thread.
Parameters
rRunnable whose run() method is to be invoked.

◆ removeDuplicateActivity()

static boolean com.bigfishgames.bfglib.bfgManager.removeDuplicateActivity (@NonNull final Activity activity)
inlinestatic
Was an orphaned copy of this activity removed to make room for the specified activity.
Parameters
activityActivity (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()

static void com.bigfishgames.bfglib.bfgManager.removePolicyListener (@NonNull final bfgPolicyListener policyListener)
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
policyListenerListener 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()

static void com.bigfishgames.bfglib.bfgManager.resume (@NonNull final Activity activityResumed)
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
activityResumedThe instance of the activity that was just resumed.

◆ setAttributionUserID()

abstract void com.bigfishgames.bfglib.bfgManager.setAttributionUserID (String userID)
abstract
Set the attribution user ID (if this option is also enabled in bfg_config)
Parameters
userIDUser ID to set.

◆ setParentViewController()

abstract void com.bigfishgames.bfglib.bfgManager.setParentViewController (Activity parent)
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
parentNew parent view controller.

◆ setSessionEndEvent()

abstract void com.bigfishgames.bfglib.bfgManager.setSessionEndEvent (@NonNull String strValue)
abstract
Accessor for sessionEndEvent member variable.
Parameters
strValueValue describing the end event.

◆ setUserID()

abstract void com.bigfishgames.bfglib.bfgManager.setUserID (long userID)
abstract
Set the current user ID.
Parameters
userIDUser ID to set.

◆ sharedInstance()

static bfgManager com.bigfishgames.bfglib.bfgManager.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 void com.bigfishgames.bfglib.bfgManager.showAlert (boolean showStore)
abstract
Shows the no network connection AlertDialog with/without store details.
Parameters
showStoreFlag controlling the display of the store details in the dialog.

◆ showPrivacy()

abstract void com.bigfishgames.bfglib.bfgManager.showPrivacy ()
abstract
Show the Privacy page using the in-game browser.

◆ showSoftKeyboard()

static void com.bigfishgames.bfglib.bfgManager.showSoftKeyboard (@NonNull final Activity activity)
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
activityThe Activity needing the keyboard shown.
Since
6.3

◆ showSupport()

abstract void com.bigfishgames.bfglib.bfgManager.showSupport ()
abstract
Launches the Help Center Activity. Requires that parentViewController is set.

◆ showTerms()

abstract void com.bigfishgames.bfglib.bfgManager.showTerms ()
abstract
Show the Terms of Use page with the in-game browser.

◆ showView()

abstract void com.bigfishgames.bfglib.bfgManager.showView (@NonNull Class<?> theClass)
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
theClassActivity class to start.

◆ showWebBrowser()

abstract void com.bigfishgames.bfglib.bfgManager.showWebBrowser (@NonNull String strLink)
abstract
Show an in-game browser displaying startPage. This method must be called on the UI thread.
Parameters
startPageURL whose content is to be displayed to the user.

◆ start()

static void com.bigfishgames.bfglib.bfgManager.start (@NonNull final Activity activityStarted)
inlinestatic
Parameters
activityStarted

◆ stop()

static void com.bigfishgames.bfglib.bfgManager.stop (@NonNull final Activity activityStopped)
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
activityStoppedThe instance of the activity that was just resumed.

◆ transformDeepLinkToRetailLink()

static String com.bigfishgames.bfglib.bfgManager.transformDeepLinkToRetailLink (@NonNull final Uri uri)
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=&lt;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
uriThe deep linking URI to transform.
Returns
A String of the transformed deep link.

◆ userID()

abstract long com.bigfishgames.bfglib.bfgManager.userID ()
abstract
Get current user ID.
Returns
Current user ID (0 if none).

Member Data Documentation

◆ BFGPROMODASHBOARD_NOTIFICATION_COLDSTART

final String com.bigfishgames.bfglib.bfgManager.BFGPROMODASHBOARD_NOTIFICATION_COLDSTART = "BFGPROMODASHBOARD_NOTIFICATION_CONTINUE"
static
Deprecated:\n Use BFG_NOTIFICATION_COLD_START instead

◆ BFGPROMODASHBOARD_NOTIFICATION_WARMSTART

final String com.bigfishgames.bfglib.bfgManager.BFGPROMODASHBOARD_NOTIFICATION_WARMSTART = "BFGPROMODASHBOARD_NOTIFICATION_APPLICATION_RESUMED"
static
Deprecated:\n Use BFG_NOTIFICATION_WARM_START instead