Banners

Are an ad with a specific size (320x50, 728x90 or 300x250) to be shown inside the same app screen app without a close option.

You can add a banner into your app declaring it on the xml layout of your Activity or Fragment:

<com.tappx.sdk.android.TappxBanner
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/tappx_banner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:txAppKey="**YOUR-APP-KEY"
        app:txAdSize="**AD-SIZE"
>

The available sizes are the following:

  • Smart: Is adjusted automatically inside the device screen. The sizes you can request are: 320x50 and 728x90.
  • 320x50: Standard Banner for phones.
  • 728x90: Standard Banner for tablets.
  • 300x250: (Mrec): Is a rectangular banner for phones and tablets.

Important: To get the best memory management you must destroy the banner once used, usually in the onDestroy() or onViewDestroyed() methods of your Activity or Fragment.

Ejemplo de uso mínimo para banners xml:

    public class MainActivity extends Activity {
        TappxBanner banner;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            banner = (TappxBanner) findViewById(R.id.tappx_banner);
        }

        @Override
        protected void onDestroy() {
            super.onDestroy();
            banner.destroy();
        }
    }

Create banner using code

To get and ad you need to create it with your App Key, set up the configuration and request the ad.

Example of banner request:

    public class MainActivity extends Activity {

        ViewGroup bannerContainer;
        TappxBanner banner;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            bannerContainer = (ViewGroup) findViewById(R.id.banner_container);
            Context context = this;
            banner = new TappxBanner(context, "**YOUR-APP-KEY**");        //Create the banner
            banner.setAdSize(AdSize.SMART_BANNER);
            bannerContainer.addView(banner);                              //add the banner to the view
            banner.loadAd();                                              //request a new ad

        }

        @Override
        protected void onDestroy() {
            super.onDestroy();
            if (banner != null) banner.destroy();
        }
    }

Listeners

You can listen to the banner events by establishing a listener with the banner.setListener() method:

    banner.setListener(new TappxBannerListener() {
        @Override
        public void onBannerLoaded(TappxBanner tappxBanner) {
            Log.v("Tappx", "Tappx: onBannerLoaded");
        }

        @Override
        public void onBannerLoadFailed(TappxBanner tappxBanner, TappxAdError tappxAdError) {
            Log.v("Tappx", "Tappx: onBannerLoadFailed " + tappxAdError);
        }

        @Override
        public void onBannerClicked(TappxBanner tappxBanner) {
            Log.v("Tappx", "Tappx: onBannerClicked");
        }

        @Override
        public void onBannerExpanded(TappxBanner tappxBanner) {
            Log.v("Tappx", "Tappx: onBannerExpanded");
        }

        @Override
        public void onBannerCollapsed(TappxBanner tappxBanner) {
            Log.v("Tappx", "Tappx: onBannerCollapsed");
        }
    });

Refresh

By default, the banner periodically shows new ads. You can change the frequency with this:

banner.setRefreshTimeSeconds(45);

or deactivate the automatic refesh:

banner.setEnableAutoRefresh(false);

Tappx © 2020