AdService
- public interface AdService
The AdService provides methods to show the AppBrain offerwall and interstitial.
- Author
AppBrain
Methods
- String getOfferWallButtonLabel(Context context)
- Parameters
context – the current
Context
- 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
context – the current
Context
- 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
- void setOfferWallMenuItemClickListener(Context context, MenuItem menuItem)
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.
- void setOfferWallMenuItemClickListener(Context context, MenuItem menuItem, OnMenuItemClickListener delegateClickListener)
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 setReturnToAppInterstitial(ReturnToAppConfig setting)
Set the behavior or the user-returns-to-app interstitial. This setting will stay active until the next time you call this function. The default setting is FROM_DASHBOARD. This is useful for instance if you offer users to remove ads, then you can call setReturnToAppInterstitial(ReturnToAppConfig.OFF).
- Parameters
setting – which setting should be active until the next time you call this function.
- 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
context – the current
Context
- Returns
Whether maybeShowInterstitial would show an interstitial or not.
- boolean showInterstitial(Context context)
Shows the interstitial if there is an internet connection.
- Parameters
context – the current
Context
- 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 https://www.appbrain.com/info/sdk for more information.
- Parameters
context – the current
Context
- 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().