Dash Stats Docs

AdService

public interface AdService

The AdService provides methods to show the AppBrain offerwall and interstitial.

Author:AppBrain

Methods

String getOfferWallButtonLabel(Context context)
Parameters:
Returns:

an internationalized String which can be used for a button or menu item which opens the offer wall. In English this is “More free apps”.

boolean maybeShowInterstitial(Context context)

Shows an interstitial activity at certain times. Our algorithm determines the frequency optimized for the highest click through rate. The interstitial is only shown when there is an internet connection.

Parameters:
Returns:

true if the interstitial was shown

boolean maybeShowInterstitial(Context context, AdOptions options)

Shows an interstitial activity at certain times. Our algorithm determines the frequency optimized for the highest click through rate. The interstitial is only shown when there is an internet connection.

Parameters:
  • context – the current Context
  • options – Interstitial options
Returns:

true if the interstitial was shown

void setOfferWallClickListener(Context context, View view)

Sets a view’s OnClickListener to open the offer wall when clicked. Unlike the method showOfferWall(), you do not need explicit approval to use this method.

Parameters:
  • context – the current Context
  • view – the button or other clickable view which should open the offer wall.
void setOfferWallClickListener(Context context, View view, OnClickListener delegateClickListener)

Sets a view’s OnClickListener to open the offer wall when clicked. Unlike the method showOfferWall(), you do not need explicit approval to use this method.

Parameters:
  • context – the current Context
  • view – the button or other clickable view which should open the offer wall.
  • delegateClickListener – an optional OnClickListener which will be called after the offer wall has been opened

Sets a menu item’s OnMenuItemClickListener to open the offer wall when clicked. Unlike the method showOfferWall(), you do not need explicit approval to use this method.

Parameters:
  • context – the current Context
  • menuItem – the menu item which should open the offer wall.

Sets a menu item’s OnMenuItemClickListener to open the offer wall when clicked. Unlike the method showOfferWall(), you do not need explicit approval to use this method.

Parameters:
  • context – the current Context
  • menuItem – the menu item which should open the offer wall.
  • delegateClickListener – an optional OnMenuItemClickListener which will be called after the offer wall has been opened
void setPopupBorder(int color, BorderSize size)

Adds a custom border around non-fullscreen ads.

Parameters:
  • color – the color of the border as ARGB int.
  • size – the size of the border as BorderSize enum value.
void setUserData(AppBrainUserData data)

Report data about the user or context to the AppBrain ads system. This may increase the monetization of your app and provide you with insightful statistics in AppBrain analytics.

boolean shouldShowInterstitial(Context context)

Query whether maybeShowInterstitial would show an interstitial now or not.

Parameters:
Returns:

Whether maybeShowInterstitial would show an interstitial or not.

boolean showInterstitial(Context context)

Shows the interstitial if there is an internet connection.

Parameters:
Returns:

true if the interstitial was shown

boolean showInterstitial(Context context, AdOptions options)

Shows the interstitial if there is an internet connection.

Parameters:
  • context – the current Context
  • options – Interstitial options
Returns:

true if the interstitial was shown

void showOfferWall(Context context)

Shows the offer wall with the list of promoted apps. You need to request explicit approval to use this method through contact@appbrain.com otherwise it won’t generate any revenue for you. See http://www.appbrain.com/info/sdk for more information.

Parameters:
void tagForChildDirectedTreatment(boolean tagForChildDirectedTreatment)

Inform the AppBrain SDK that any subsequent requests should assume that the current user falls under the ‘Child Online Privacy Protection Act’ (COPPA). You don’t need to explicitly set this if you marked your app as child-directed using the appbrain.child_directed property in the Android manifest.

Parameters:
  • tagForChildDirectedTreatment – Set this to true if the user is less than 13 years old (or for some other reason falls under the COPPA rule).
AdListAdapter wrapListAdapter(Context context, ListAdapter adapter)

Wraps your ListAdapter in an AdListAdapter, which automatically inserts ads in your ListView.

Parameters:
  • context – the current Context
  • adapter – your own ListAdapter
Returns:

the AdListAdapter which wraps your own adapter. In your ListView’s OnItemClickListener you can use the AdListAdapter to determine the actual position of the item which was clicked, by calling AdListAdapter.getItemPosition().

AdListAdapter wrapListAdapter(Context context, ListAdapter adapter, int layoutId, int iconId, int titleId, int descriptionId)

Wraps your ListAdapter in an AdListAdapter, which automatically inserts ads in your ListView.

Parameters:
  • context – the current Context
  • adapter – your own ListAdapter
  • layoutId – the ID of your custom layout view used to display ads.
  • iconId – the ID of an ImageView inside your custom layout, to display the ad’s icon.
  • titleId – the ID of a TextView inside your custom layout, to display the ad’s title.
  • descriptionId – the ID of a TextView inside your custom layout, to display the ad’s description.
Returns:

the AdListAdapter which wraps your own adapter. In your ListView’s OnItemClickListener you can use the AdListAdapter to determine the actual position of the item which was clicked, by calling AdListAdapter.getItemPosition().

AdListAdapter wrapListAdapter(Context context, ListAdapter adapter, AdLayoutCreator layoutCreator, int iconId, int titleId, int descriptionId)

Wraps your ListAdapter in an AdListAdapter, which automatically inserts ads in your ListView.

Parameters:
  • context – the current Context
  • adapter – your own ListAdapter
  • layoutCreator – your custom implementation of AdLayoutCreator, which will be used to create the view to display ads.
  • iconId – the ID of an ImageView inside your custom layout, to display the ad’s icon.
  • titleId – the ID of a TextView inside your custom layout, to display the ad’s title.
  • descriptionId – the ID of a TextView inside your custom layout, to display the ad’s description.
Returns:

the AdListAdapter which wraps your own adapter. In your ListView’s OnItemClickListener you can use the AdListAdapter to determine the actual position of the item which was clicked, by calling AdListAdapter.getItemPosition().

AdRecyclerAdapter wrapRecyclerAdapter(Context context, Object adapter)

Wraps your RecyclerView.Adapter in an AdRecyclerAdapter, which automatically inserts ads in you RecyclerView.

Parameters:
  • context – the current Context
  • adapter – your own RecyclerView.Adapter. This parameter has type Object so the AppBrain SDK can also support projects that don’t include the RecyclerView library, but you must pass a RecyclerView.Adapter here.
Returns:

the AdRecyclerAdapter which wraps your own adapter. If you want to determine which item was clicked, you can use AdRecyclerAdapter.getItemPosition() to determine the correct position.

AdRecyclerAdapter wrapRecyclerAdapter(Context context, Object adapter, int layoutId, int iconId, int titleId, int descriptionId)

Wraps your RecyclerView.Adapter in an AdRecyclerAdapter, which automatically inserts ads in you RecyclerView.

Parameters:
  • context – the current Context
  • adapter – your own RecyclerView.Adapter. This parameter has type Object so AppBrain SDK can also support projects that don’t include the RecyclerView library, but you must pass a RecyclerView.Adapter here.
  • layoutId – the ID of your custom layout view used to display ads.
  • iconId – the ID of an ImageView inside your custom layout, to display the ad’s icon.
  • titleId – the ID of a TextView inside your custom layout, to display the ad’s title.
  • descriptionId – the ID of a TextView inside your custom layout, to display the ad’s description.
Returns:

the AdRecyclerAdapter which wraps your own adapter. If you want to determine which item was clicked, you can use AdRecyclerAdapter.getItemPosition() to determine the correct position.

AdRecyclerAdapter wrapRecyclerAdapter(Context context, Object adapter, AdLayoutCreator layoutCreator, int iconId, int titleId, int descriptionId)

Wraps your RecyclerView.Adapter in an AdRecyclerAdapter, which automatically inserts ads in you RecyclerView.

Parameters:
  • context – the current Context
  • adapter – your own RecyclerView.Adapter. This parameter has type Object so AppBrain SDK can also support projects that don’t include the RecyclerView library, but you must pass a RecyclerView.Adapter here.
  • layoutCreator – your custom implementation of AdLayoutCreator, which will be used to create the view to display ads.
  • iconId – the ID of an ImageView inside your custom layout, to display the ad’s icon.
  • titleId – the ID of a TextView inside your custom layout, to display the ad’s title.
  • descriptionId – the ID of a TextView inside your custom layout, to display the ad’s description.
Returns:

the AdRecyclerAdapter which wraps your own adapter. If you want to determine which item was clicked, you can use AdRecyclerAdapter.getItemPosition() to determine the correct position.