public class MonetizationManager extends Object
The entry point for the MonetizationSDK. This manager provides methods to call different ad types and offerwalls.
Note: When the application is closing release()
should be called to release the resources allocated by this manager.
Reworked [Mani Selvaraju] Removed initialize method and included appId,publisherId to CreateSession
Modifier and Type | Field and Description |
---|---|
private static MonetizationManager |
instance
The manager is a singleton and this field contains the reference to the only instance of this object.
|
private MonetizationSDK |
monetizationSDK
The instance of SDK wrapper class.
|
Modifier | Constructor and Description |
---|---|
private |
MonetizationManager()
The class is singleton and the constructor is private.
|
Modifier and Type | Method and Description |
---|---|
static void |
actionTaken(int actionId)
The ActionTaken operation calls back to the nativeX servers and communicates that a trackable action has completed.
|
private static void |
checkInstance()
This method checks for an instance of the manager and if there is no instance it throws
NullPointerException . |
private static void |
checkPlacementName(String name,
String apiname)
This method checks for null or empty string for placement name,if found throws
NullPointerException . |
private static void |
checkPosition(Rect position,
com.nativex.monetization.enums.BannerPosition enumPosition,
String placementName) |
private static void |
createInstance() |
static void |
createSession()
Deprecated.
use
createSession(Context, String, SessionListener) or
createSession(Context, String, String, SessionListener)
Establishes a session with the NativeX servers. The session is registering the device with our servers and personalizes the offer selection for it. Note: The network call is asynchronous. |
static void |
createSession(Context context,
ApplicationInputs inputs,
com.nativex.monetization.listeners.SessionListener listener)
Establishes a session with the NativeX servers.
|
static void |
createSession(Context context,
String appId,
com.nativex.monetization.listeners.SessionListener listener)
Establishes a session with the NativeX servers.
|
static void |
createSession(Context context,
String appId,
String publisherUserId,
com.nativex.monetization.listeners.SessionListener listener)
Establishes a session with the NativeX servers.
|
static void |
createSession(com.nativex.monetization.listeners.SessionListener listener)
Deprecated.
use
createSession(Context, String, SessionListener) or
createSession(Context, String, String, SessionListener)
Establishes a session with the NativeX servers. The session is registering the device with our servers and personalizes the offer selection for it. Accepts a callback interface implementation. Note: The network call is asynchronous. |
static void |
disableLegacyDeviceIdentifiers(boolean disable)
Disable using legacy device identifiers [IMEI and Android ID] as unique identifiers.
|
static void |
dismissAd(com.nativex.monetization.enums.NativeXAdPlacement name)
Removes an ad from the screen and releases it's resources.
|
static void |
dismissAd(String customPlacement)
Removes an ad from the screen and releases it's resources.
|
static void |
dismissBannerAd(com.nativex.monetization.enums.NativeXAdPlacement name)
Removes a banner from the screen and releases it's resources.
|
static void |
dismissBannerAd(String customPlacement)
Removes a banner from the screen and releases it's resources.
|
static void |
enableLogging(boolean isEnabled)
Enables the SDK logging.
|
static void |
fetchAd(Activity activity,
com.nativex.monetization.enums.NativeXAdPlacement name,
com.nativex.monetization.listeners.OnAdEventBase listener)
Fetches an ad and stores in the memory ready to be shown.
|
static void |
fetchAd(Activity activity,
String customPlacement,
com.nativex.monetization.listeners.OnAdEventBase listener)
Fetches an ad and stores it in the memory ready to be shown.
|
static void |
fetchBannerAd(Activity activity,
com.nativex.monetization.enums.NativeXAdPlacement name,
com.nativex.monetization.listeners.OnAdEventBase listener)
Fetches a banner and stores it in the memory ready to be shown.
|
static void |
fetchBannerAd(Activity activity,
String customPlacement,
com.nativex.monetization.listeners.OnAdEventBase listener)
Fetches a banner and stores it in the memory ready to be shown.
|
static String |
getSessionId()
Checks for session id and returns it if available.
|
static void |
initialize(Activity context,
ApplicationInputs inputs)
Deprecated.
use
createSession(Context, String, SessionListener) or
createSession(Context, String, String, SessionListener)
Initializes the SDK. This method initializes various managers that the SDK requires to run. This methods accepts the application data as a bundle. |
static void |
initialize(Activity context,
String applicationName,
int appId,
String publisherUserId,
String packageName)
Deprecated.
use
createSession(Context, String, SessionListener) or
createSession(Context, String, String, SessionListener)
Initializes the SDK. This method initializes various managers that the SDK requires to run. This method accepts the application data as parameters. |
private static boolean |
isAndroidVersionSupported()
If device platform version is less than or equals to 2.2 (Froyo).
|
static boolean |
isInitialized()
Checks if this manager is initialized.
|
static void |
redeemCurrency()
Sends RedeemCurrency network call to the server.
|
static void |
release()
Releases the resources allocated by the SDK and ends the currently established session.
|
static void |
reloadBannerAd(com.nativex.monetization.enums.NativeXAdPlacement name)
Loads new ad in a banner.
|
static void |
reloadBannerAd(String customPlacement)
Loads new ad in a banner.
|
static void |
setBannerAdPosition(com.nativex.monetization.enums.NativeXAdPlacement name,
com.nativex.monetization.enums.BannerPosition position)
Sets the custom position of a banner.
|
static void |
setBannerAdPosition(com.nativex.monetization.enums.NativeXAdPlacement name,
Rect position)
Sets the custom position of a banner.
|
static void |
setBannerAdPosition(String customPlacement,
com.nativex.monetization.enums.BannerPosition position)
Sets the custom position of a banner.
|
static void |
setBannerAdPosition(String customPlacement,
Rect position)
Sets the custom position of a banner.
|
static void |
setCurrencyListener(com.nativex.monetization.listeners.CurrencyListenerBase listener)
Sets a listener in the SDK that will provide callback when the user completes an offer and is awarded with virtual currency.
|
static void |
setTheme(com.nativex.monetization.theme.Theme theme)
Sets the theme of the SDK.
|
static void |
showAd(Activity activity,
com.nativex.monetization.enums.NativeXAdPlacement name)
Show an ad.
|
static void |
showAd(Activity activity,
com.nativex.monetization.enums.NativeXAdPlacement name,
com.nativex.monetization.listeners.OnAdEventBase listener)
Show an ad.
|
static void |
showAd(Activity activity,
String customPlacement)
Show an ad.
|
static void |
showAd(Activity activity,
String customPlacement,
com.nativex.monetization.listeners.OnAdEventBase listener)
Show an ad.
|
static void |
showBannerAd(Activity activity,
com.nativex.monetization.enums.NativeXAdPlacement placement,
com.nativex.monetization.enums.BannerPosition position)
Shows a banner.
|
static void |
showBannerAd(Activity activity,
com.nativex.monetization.enums.NativeXAdPlacement name,
com.nativex.monetization.enums.BannerPosition position,
com.nativex.monetization.listeners.OnAdEventBase listener)
Shows a banner ad.
|
static void |
showBannerAd(Activity activity,
com.nativex.monetization.enums.NativeXAdPlacement name,
Rect position,
com.nativex.monetization.listeners.OnAdEventBase listener)
Shows a banner ad.
|
static void |
showBannerAd(Activity activity,
String customPlacement,
com.nativex.monetization.enums.BannerPosition position)
Shows a banner.
|
static void |
showBannerAd(Activity activity,
String customPlacement,
com.nativex.monetization.enums.BannerPosition position,
com.nativex.monetization.listeners.OnAdEventBase listener)
Shows a banner ad.
|
static void |
showBannerAd(Activity activity,
String customPlacement,
Rect position)
Shows a banner.
|
private static void |
showBannerAd(Activity activity,
String customPlacement,
Rect position,
com.nativex.monetization.enums.BannerPosition adPosition,
com.nativex.monetization.listeners.OnAdEventBase listener) |
static void |
showBannerAd(Activity activity,
String customPlacement,
Rect position,
com.nativex.monetization.listeners.OnAdEventBase listener)
Shows a banner ad.
|
static void |
trackInAppPurchase(com.nativex.common.billingtracking.BillingInputs inputs)
Sends a tracking call to the server with information about a purchase that the user completed.
|
static void |
trackInAppPurchase(String storeProductId,
String storeTransactionId,
String storeTransactionTimeUTC,
float costPerItem,
String currencyLocale,
int quantity,
String productTitle)
Sends a tracking call to the server with information about a purchase that the user completed.
|
static void |
update(Activity activity)
In case the activity needs to be recreated (due to configuration change for example), the banner has to be detached from the old instance and re-attached to the new one.
|
private static MonetizationManager instance
private MonetizationSDK monetizationSDK
private MonetizationManager()
private static void createInstance()
private static void checkInstance()
NullPointerException
.NullPointerException
- This exception is thrown when the manager is not initialized.private static boolean isAndroidVersionSupported()
@Deprecated public static void initialize(Activity context, ApplicationInputs inputs)
createSession(Context, String, SessionListener)
or
createSession(Context, String, String, SessionListener)
Initializes the SDK. This method initializes various managers that the SDK requires to run. This methods accepts the application data as a bundle.context
- Constants
. The context instance is required for the SDK to be able to create UI elements like the offerwall.inputs
- ApplicationInputs
. The application data is passed here as a bundle.@Deprecated public static void initialize(Activity context, String applicationName, int appId, String publisherUserId, String packageName)
createSession(Context, String, SessionListener)
or
createSession(Context, String, String, SessionListener)
Initializes the SDK. This method initializes various managers that the SDK requires to run. This method accepts the application data as parameters.context
- Constants
. The context instance is required for the SDK to be able to create UI elements like the offerwall.applicationName
- String
. The application name to display in the offerwall.appId
- Integer
. The appId provided by NativeX support team for your app.publisherUserId
- String
. This is developer payload.packageName
- String
. The package name of the application.@Deprecated public static void createSession()
createSession(Context, String, SessionListener)
or
createSession(Context, String, String, SessionListener)
Establishes a session with the NativeX servers. The session is registering the device with our servers and personalizes the offer selection for it. @Deprecated public static void createSession(com.nativex.monetization.listeners.SessionListener listener)
createSession(Context, String, SessionListener)
or
createSession(Context, String, String, SessionListener)
Establishes a session with the NativeX servers. The session is registering the device with our servers and personalizes the offer selection for it. Accepts a callback interface implementation. listener
- SessionListener
. The listener that will provide callback when the CreateSession request is done.public static void createSession(Context context, String appId, com.nativex.monetization.listeners.SessionListener listener)
context
- Constants
. The context instance is required for the SDK to be able to create UI elements like the offerwall.appId
- Integer
. The appId provided by NativeX support team for your app.listener
- SessionListener
. The listener that will provide callback when the CreateSession request is done.public static void createSession(Context context, String appId, String publisherUserId, com.nativex.monetization.listeners.SessionListener listener)
context
- Constants
. The context instance is required for the SDK to be able to create UI elements like the offerwall.appId
- Integer
. The appId provided by NativeX support team for your app.publisherUserId
- String
. This is developer payload.listener
- SessionListener
. The listener that will provide callback when the CreateSession request is done.public static void createSession(Context context, ApplicationInputs inputs, com.nativex.monetization.listeners.SessionListener listener)
context
- Constants
. The context instance is required for the SDK to be able to create UI elements like the offerwall.inputs
- ApplicationInputs
. Bundle that contains application data.listener
- SessionListener
. The listener that will provide callback when the CreateSession request is done.public static void actionTaken(int actionId)
actionId
- The action id is provided by nativeX and identifies the particular action that your app is tracking.public static void disableLegacyDeviceIdentifiers(boolean disable)
disable
- Boolean
true - legacy identifiers disabled; will only be used when advertising ID is unavailable.
false -legacy identifiers enabled; if advertising ID is also available, it will not be linked to the legacy identifiers.public static void setCurrencyListener(com.nativex.monetization.listeners.CurrencyListenerBase listener)
listener
- CurrencyListenerBase
. This listener may be implementation of either CurrencyListenerV1
or CurrencyListenerV2
.public static void redeemCurrency()
context
- Activity
. The activity is required for the dialog that will pop when the network call is completed and there are virtual currencies awarded to the user.public static void enableLogging(boolean isEnabled)
isEnabled
- Boolean
.true - enabled, false - no log.public static String getSessionId()
String
. The session id generated from the server or null if not available.public static void trackInAppPurchase(com.nativex.common.billingtracking.BillingInputs inputs)
inputs
- BillingInputs
. A bundle with information about the purchase to send to the server.public static void trackInAppPurchase(String storeProductId, String storeTransactionId, String storeTransactionTimeUTC, float costPerItem, String currencyLocale, int quantity, String productTitle)
storeProductId
- String
The product id of the store item.storeTransactionId
- String
The transaction id.storeTransactionTimeUTC
- String
The time the purchase was performed.costPerItem
- Float
The cost of the item.currencyLocale
- String
The locale of the currency used to pay for the purchase.quantity
- Integer
The quantity of items purchased.productTitle
- String
The name of the product.public static void setTheme(com.nativex.monetization.theme.Theme theme)
theme
- Theme
. The theme for the SDK visual elements to use.public static boolean isInitialized()
Boolean
. true - the manager is initialized, false - call initialize().public static void release()
public static final void showAd(Activity activity, com.nativex.monetization.enums.NativeXAdPlacement name)
activity
- Activity
. The activity to create the ad visual elements from.name
- NativeXAdPlacement
. A pre-defined list of strings describing the interaction point of an ad within your game.public static final void showAd(Activity activity, String customPlacement)
public static final void showAd(Activity activity, com.nativex.monetization.enums.NativeXAdPlacement name, com.nativex.monetization.listeners.OnAdEventBase listener)
activity
- Activity
. The activity to create the ad visual elements from.name
- NativeXAdPlacement
. A pre-defined list of strings describing the interaction point of an ad within your game.listener
- OnAdEventBase
. An implementation of OnAdEventBase interface to provide callback.public static final void showAd(Activity activity, String customPlacement, com.nativex.monetization.listeners.OnAdEventBase listener)
public static final void showBannerAd(Activity activity, String customPlacement, Rect position)
public static final void showBannerAd(Activity activity, String customPlacement, com.nativex.monetization.enums.BannerPosition position)
public static final void showBannerAd(Activity activity, com.nativex.monetization.enums.NativeXAdPlacement placement, com.nativex.monetization.enums.BannerPosition position)
activity
- Activity
. The activity to create the ad visual elements from.placement
- NativeXAdPlacement
. Default placement categories used as the name of the ad configurable on the NativeX self-service web site.position
- BannerPosition
. Choose a predefined position.public static final void showBannerAd(Activity activity, com.nativex.monetization.enums.NativeXAdPlacement name, Rect position, com.nativex.monetization.listeners.OnAdEventBase listener)
public static final void showBannerAd(Activity activity, com.nativex.monetization.enums.NativeXAdPlacement name, com.nativex.monetization.enums.BannerPosition position, com.nativex.monetization.listeners.OnAdEventBase listener)
activity
- Activity
. The activity to create the ad visual elements from.name
- NativeXAdPlacement
. Default placement categories used as the name of the ad configurable on the NativeX self-service web site.position
- BannerPosition
. Choose a predefined position.public static final void showBannerAd(Activity activity, String customPlacement, Rect position, com.nativex.monetization.listeners.OnAdEventBase listener)
public static final void showBannerAd(Activity activity, String customPlacement, com.nativex.monetization.enums.BannerPosition position, com.nativex.monetization.listeners.OnAdEventBase listener)
private static final void showBannerAd(Activity activity, String customPlacement, Rect position, com.nativex.monetization.enums.BannerPosition adPosition, com.nativex.monetization.listeners.OnAdEventBase listener)
private static final void checkPosition(Rect position, com.nativex.monetization.enums.BannerPosition enumPosition, String placementName)
public static final void update(Activity activity)
activity
- Activity
. The activity to update the ad with.public static final void fetchAd(Activity activity, com.nativex.monetization.enums.NativeXAdPlacement name, com.nativex.monetization.listeners.OnAdEventBase listener)
activity
- Activity
. The activity to create the ad visual elements from.name
- NativeXAdPlacement
. A pre-defined list of strings describing the interaction point of an ad within your game.listener
- OnAdEventBase
. An implementation of OnAdEventBase interface to provide callback.public static final void fetchAd(Activity activity, String customPlacement, com.nativex.monetization.listeners.OnAdEventBase listener)
public static final void fetchBannerAd(Activity activity, com.nativex.monetization.enums.NativeXAdPlacement name, com.nativex.monetization.listeners.OnAdEventBase listener)
activity
- Activity
. The activity to create the ad visual elements from.name
- NativeXAdPlacement
. Default placement categories used as the name of the ad configurable on the NativeX self-service web site.listener
- OnAdEventBase
. An implementation of OnAdEventBase interface to provide callback.public static final void fetchBannerAd(Activity activity, String customPlacement, com.nativex.monetization.listeners.OnAdEventBase listener)
public static final void reloadBannerAd(com.nativex.monetization.enums.NativeXAdPlacement name)
name
- NativeXAdPlacement
. Default placement categories used as the name of the ad configurable on the NativeX self-service web site.public static final void reloadBannerAd(String customPlacement)
customPlacement
- String
. The name of the ad configurable on the NativeX self-service web site.public static final void setBannerAdPosition(com.nativex.monetization.enums.NativeXAdPlacement name, Rect position)
name
- NativeXAdPlacement
. Default placement categories used as the name of the ad configurable on the NativeX self-service web site.position
- Rect
. A Rect that describes the position of the ad.public static final void setBannerAdPosition(com.nativex.monetization.enums.NativeXAdPlacement name, com.nativex.monetization.enums.BannerPosition position)
name
- NativeXAdPlacement
. Default placement categories used as the name of the ad configurable on the NativeX self-service web site.position
- BannerPosition
. Choose a predefined position.public static final void setBannerAdPosition(String customPlacement, com.nativex.monetization.enums.BannerPosition position)
customPlacement
- String
. The name of the ad configurable on the NativeX self-service web site.position
- BannerPosition
. Choose a predefined position.public static final void setBannerAdPosition(String customPlacement, Rect position)
public static final void dismissBannerAd(com.nativex.monetization.enums.NativeXAdPlacement name)
name
- NativeXAdPlacement
. Default placement categories used as the name of the ad configurable on the NativeX self-service web site.public static final void dismissBannerAd(String customPlacement)
customPlacement
- String
. The name of the ad configurable on the NativeX self-service web site.public static final void dismissAd(com.nativex.monetization.enums.NativeXAdPlacement name)
name
- NativeXAdPlacement
. A pre-defined list of strings describing the interaction point of an ad within your game.public static final void dismissAd(String customPlacement)
customPlacement
- String
. The name of the ad configurable on the NativeX self-service web site.private static void checkPlacementName(String name, String apiname)
NullPointerException
.NullPointerException
- This exception is thrown when the placement name is null or empty string.