Skip to content

Banner

Android apps are build of several view objects. An ADvantage banner is also a view (to be more exact, it is an RelativeLayout) displaying HTML5 ads that respond to user interaction (touch, wipe, click and etc.).

To add a banner to your view it takes only a few lines of code:

  • Create an new instance of ADvantage instance in code (pass your license key, siteId and position to its constructor)
banner = new Advantage(this, "<LICENSE_KEY>", "<SITE_ID>", "<POSITION>");
banner.setSSLEnabled(true);

//Optionally add your custom loading animation
banner.setLoadingAnimationImageViewResourceId(R.drawable.loading_animation);

Note

  • You have to enable SSL before calling showAd().
  • SSL enabled is required for every new license.
  • For customers where SSL has not yet been activated and you would like to switch, please contact us.

  • Add the ADvantage instance to your layout/content view
<LinearLayout
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:id="@+id/container"/>
LinearLayout container = (LinearLayout) findViewById(R.id.container);

//Add ADvantage view to your layout
container.addView(banner);
  • Add the EventHandler in order to handle ADvantage events (For more information please visit ADvantage events):
//Add the EventHandlers to handle ADvantage events
banner.setEventHandler(...);
  • Load and show the ad via your ADvantage instances showAd() method.
//Show banner...
banner.showAd();
  • Override onPause and onResume methods for better memory handling (For more information please visit ADvantage lifecycle):
// Important methods for the ADvantage lifecycle
@Override
protected void onPause() {
    super.onPause();

    if(banner!=null)
        banner.setActivityState(ActivityState.PAUSE);
}

@Override
protected void onResume() {
    super.onResume();

    if(banner!=null)
        banner.setActivityState(ActivityState.RESUME);
}

Tip

The best place to do all this is in your Activity's onCreate() method.