Interface AdService


public interface AdService
The AdService provides methods to show the AppBrain offerwall and interstitial.
  • Method Details

    • shouldShowInterstitial

      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.
    • maybeShowInterstitial

      @Deprecated boolean maybeShowInterstitial(Context context)
      Deprecated.
      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
    • maybeShowInterstitial

      @Deprecated boolean maybeShowInterstitial(Context context, AdOptions options)
      Deprecated.
      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
    • showInterstitial

      @Deprecated boolean showInterstitial(Context context)
      Deprecated.
      Shows the interstitial if there is an internet connection.
      Parameters:
      context - the current Context
      Returns:
      true if the interstitial was shown
    • showInterstitial

      @Deprecated boolean showInterstitial(Context context, AdOptions options)
      Deprecated.
      Shows the interstitial if there is an internet connection.
      Parameters:
      context - the current Context
      options - Interstitial options
      Returns:
      true if the interstitial was shown
    • showOfferWall

      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
    • setOfferWallClickListener

      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.
    • setOfferWallClickListener

      void setOfferWallClickListener(Context context, View 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
    • setOfferWallMenuItemClickListener

      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.
    • setOfferWallMenuItemClickListener

      void setOfferWallMenuItemClickListener(Context context, MenuItem 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
    • getOfferWallButtonLabel

      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".
    • unityOfferWallButtonClick

      void unityOfferWallButtonClick(Context context)
      Show the offer wall from a Unity button click. Only works in Unity apps.
      Parameters:
      context - the current Context
    • wrapListAdapter

      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().
    • wrapListAdapter

      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().
    • wrapListAdapter

      AdListAdapter wrapListAdapter(Context context, ListAdapter adapter, AdListAdapter.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().
    • setUserData

      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.
    • tagForChildDirectedTreatment

      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).
    • setPopupBorder

      void setPopupBorder(int color, AdService.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 AdService.BorderSize enum value.
    • setReturnToAppInterstitial

      void setReturnToAppInterstitial(AdService.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.