appTV – Android Advertising SDK (Banner Integration)

June 5, 2020

Before You Start :: We support Android Operating Systems Version 4.4 (API level 19) and up. If your app is built for lower version devices – reach out to us at sdk@appTV.com

Step 1 – Add the appTV-SDK to Your Project

Manual Download

1. Download appTV-SDK-4.0.1.aar and place it in your application’s libs folder.

2. Make sure that the below is added to your app/src/build.gradle under the dependencies section:

Example
implementation files(‘libs/appTV-SDK-4.0.1.aar’)

Step 2 – Update build.gradle

Add the following items to your app/src/build.gradle file under the dependencies section.

Example
implementation ‘com.android.volley:volley:1.1.1’
implementation(‘com.google.android.gms:play-services-ads-identifier: 16.0.0’) implementation(‘com.danikula:videocache:2.7.1’)

Step 3 – Initialize the SDK

  • In your ‘Application’ class or on your Main activity.
  • Please replace SEC_ID with Section Id that is provided to you by your Account Manager.
Example
AppTvSDK.init(this, SEC_ID);

 

Step 4 – Create Banner layout

  • Create a new layout for the banner ad – to be placed at the desired location in your app.
Example
<FrameLayout
   android:id=”@+id/atvbanner”
   android:layout_width=”wrap_content”
   android:layout_height=”wrap_content”   
android:orientation=”vertical”    />

  • Manifested below is an example which initialises AppTv SDK, creates and loads a banner under the activity onCreate() method.
Example
@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   context = this.getApplicationContext();
 
   // YOUR APP CODE
   AppTvSDK.init(this, SEC_ID);
   mBannerAd = AppTvSDK.createBanner(this, 320, 50, new AppTvSDK.ATVBannerListener() {
       @Override
       public void onBannerLoadFailed(AppTvSDK.ATVBanner atvBanner, String s) {
           Log.d(“AppTvLog”, “banner ” + s);
       }
       @Override
       public void onBannerLoaded(AppTvSDK.ATVBanner atvBanner) {
           Log.d(“AppTvLog”, “banner loaded”);
 
           // ֿA loaded banner is added to your placeholder
           FrameLayout bannerLayout = findViewById(R.id.atvbanner);
           AppTvSDK.addBannerViewTo(mBannerAd, bannerLayout);
       }
       @Override
       public void onBannerShown(AppTvSDK.ATVBanner atvBanner) {
       }
       @Override
       public void onBannerClosed(AppTvSDK.ATVBanner atvBanner) {
       }
       @Override
       public void onBannerFinished(AppTvSDK.ATVBanner atvBanner) {
       }
       @Override
       public void onBannerClicked(AppTvSDK.ATVBanner atvBanner, String s) {
       }
   });
 
AppTvSDK.loadBanner(mBannerAd); //Banner load trigger
 
}
 

Load a banner

  • In order to load a banner please use this below method.
Example
AppTvSDK.loadBanner(mBannerAd);

Step 5 – Verify your integration – Fetch our test ads

When integrating your app with appTv, it makes sense to use our Test Section Id to make sure your integration works properly. Unlike real Inventory Section Ids, that may return no-ad when there is currently no campaign running in a specific country, our Test Section Id always returns an ad.

  • Sample Ad section-> SEC_ID: 7085
    Please contact your account manager to receive your owen SEC_ID

 

Additional Available methods – Banner

  • Deallocating the banner instance and closing the ad.
Example
AppTvSDK.releaseBanner(atvBanner);

Important notice for For applications running on devices with lower android API version (<20)
Please Add/Edit the following to the Android  manifest file.

Example
<?xml version=”1.0″ encoding=”utf-8″?> <manifest xmlns:android=”http://schemas.android.com/apk/res/android”
    package=”com.YOUR.PACAGENAME” xmlns:tools=”http://schemas.android.com/tools”> <uses-sdk tools:overrideLibrary=”com.apptv.android”/>

** com.YOUR.PACAGENAME should be replaced with your own app package name

Done!

Please contact us for integration issues at sdk@appTV.com

Author

appTV