How to implement AdColony AD (Banner/Interstitial/Rewarded) SDK in Android (Example Code)

Share Post
  •  
  •  
  •  
  • 2
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    2
    Shares

Please Subscribe Youtube| Like Facebook | Follow Twitter

For Kotlin follow this article

Introduction

In this article we will learn how to implement AdColony Banner/Interstitial/Rewarded Ads in android application. AdColony allows you to monetize your app by displaying ads.

Our Example

In our example we have two button which will display Interstitial and Reward video Ads respectively on button click. At the bottom of app screen we will display banner ad.

Requirements:

  1. Android Project/App in which AdColony ads to be implemented
  2. AdColony Account

Steps

Follow below steps

1) Create or Sign-in AdColony Account and add application

2) Create Ad units zone id in AdColony account

3) Integrate and code AdColony ads in your app

4) Run and test your application

1) Create or Sign-in AdColony Account and add application

Sign-in to or sign-up for an AdColony account.

After creating account select MONETIZATION -> Setup New App

Fill details according to your requirements

After filling details click on create.

Now after adding app next step is to create ad unit zone id.

2) Create Ad units zone id in AdColony account

Click on created app and copy AdColony App ID and paste it in a text file (we will need this later).

Then click on Setup New Ad Zone to create ad units (Banner/Interstitial/Rewarded)

Set Setting for Banner Ad according to your requirements.

Show test ads only (for dev or debug)? Is set to yes during development, change it to no during production.

After creating banner ad, open it and copy zone id in text file (we will need this later).

Now set Setting for Interstitial Ad according to your requirements and copy its zone id in text file.

Similarly set Setting for Reward Ad (virtual currency, reward amount) according to your requirements and copy its zone id in text file.

After creating (Banner/Interstitial/Rewarded) ad unit, next step is to integrate adcolony in your app.

3) Integrate and code AdColony ads in your app

At project level build.gradle file add maven { url  “https://adcolony.bintray.com/AdColony”}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url  "https://adcolony.bintray.com/AdColony"
        }
    }
}

At app level build.gradle file add adcolony sdk dependency and sync project

implementation 'com.adcolony:sdk:4.1.4'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'

In manifest file add internet and vibrate permission and inside application tag add attribute android:usesCleartextTraffic=”true”. Also add two Adcolony activities inside application tag, it is requirement for ads.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.programtown.example">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true"
        >
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.adcolony.sdk.AdColonyInterstitialActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            android:hardwareAccelerated="true"/>
        <activity android:name="com.adcolony.sdk.AdColonyAdViewActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            android:hardwareAccelerated="true"/>
    </application>

</manifest>

In proguard-rules.pro file add below ProGuard Configuration

# For communication with AdColony's WebView
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}

Below is code for layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical"
    >

    <Button
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="Display InterstitialAd"
        android:onClick="displayInterstitialAd"
        ></Button>
    <Button
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="Display Reward Video Ad"
        android:onClick="displayRewardVideoAd"
        ></Button>
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="5"
        ></View>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical"
        android:gravity="center"
        android:id="@+id/colony"
        >

    </LinearLayout>

</LinearLayout>

Now Inside MainActivity add app id and (Banner/Interstitial/Rewarded) zone id which was copied during step 2 in a text file. Here we have used our own sample ids replace it with your own ids.

private final static String APP_ID = "app7dd43d11ae344f74af";
private final static String BANNER_ZONE_ID = "vz5ccc44c8de0c43f7a8";
private final static String INTERSTITIAL_ZONE_ID = "vz614303d8339f4b95b4";
private final static String REWARD_ZONE_ID = "vze9db182f005c424597";
public final static String[] AD_UNIT_Zone_Ids = new String[] {BANNER_ZONE_ID,INTERSTITIAL_ZONE_ID,REWARD_ZONE_ID};

On app start we have called initColonySdk() method which will initialize AdColony SDK.

private void initColonySdk(){
        // Construct optional app options object to be sent with configure
        AdColonyAppOptions appOptions = new AdColonyAppOptions().setKeepScreenOn(true);;
        // Configure AdColony in your launching Activity's onCreate() method so that cached ads can
        // be available as soon as possible.
        AdColony.configure(getApplication(), appOptions, APP_ID, AD_UNIT_Zone_Ids);
    }

initBannerAd() method will request and load banner ad at the bottom of screen. bannerListener is defined to write your custom action on particular ad event. On onRequestFilled() method we will get adColonyAdView object from adcolony Ad Server.

private void initBannerAd() {
        bannerConatiner = (LinearLayout)findViewById(R.id.colony);
   
        AdColonyAdViewListener bannerListener = new AdColonyAdViewListener() {
            @Override
            public void onRequestFilled(AdColonyAdView adColonyAdView) {
                //Remove previous ad view if present.
                if (bannerConatiner.getChildCount() > 0) {
                    bannerConatiner.removeView(bannerAdColony);
                }
                bannerConatiner.addView(adColonyAdView);
                bannerAdColony = adColonyAdView;
            }
            @Override
            public void onRequestNotFilled(AdColonyZone zone) {
                super.onRequestNotFilled(zone);
            }
            @Override
            public void onOpened(AdColonyAdView ad) {
                super.onOpened(ad);
            }
            @Override
            public void onClosed(AdColonyAdView ad) {
                super.onClosed(ad);
            }
            @Override
            public void onClicked(AdColonyAdView ad) {
                super.onClicked(ad);
            }
            @Override
            public void onLeftApplication(AdColonyAdView ad) {
                super.onLeftApplication(ad);
            }
        };
        // Optional Ad specific options to be sent with request
        AdColonyAdOptions adOptions = new AdColonyAdOptions();
        //Request Ad
        AdColony.requestAdView(BANNER_ZONE_ID, bannerListener, AdColonyAdSize.BANNER, adOptions);
    }

In initInterstitialAd() method will request and load Interstitial Ad. interstitialListener is defined to write your custom action on particular ad event. On onRequestFilled() method we will get AdColonyInterstitial object from adcolony Ad Server. On onClosed() method we have again requested next Interstitial ad.

private void initInterstitialAd() {
        // Set up listener for interstitial ad callbacks. You only need to implement the callbacks
        // that you care about. The only required callback is onRequestFilled, as this is the only
        // way to get an ad object.
        interstitialListener = new AdColonyInterstitialListener() {
            @Override
            public void onRequestFilled(AdColonyInterstitial adIn) {
                // Ad passed back in request filled callback, ad can now be shown
                interstitialAdColony = adIn;
                isInterstitialLoaded=true;
            }
            @Override
            public void onRequestNotFilled(AdColonyZone zone) {
                super.onRequestNotFilled(zone);
            }
            @Override
            public void onOpened(AdColonyInterstitial ad) {
                super.onOpened(ad);
            }
            @Override
            public void onClosed(AdColonyInterstitial ad) {
                super.onClosed(ad);
                //request new Interstitial Ad on close
                AdColony.requestInterstitial(INTERSTITIAL_ZONE_ID, interstitialListener, interstitialAdOptions);
            }
            @Override
            public void onClicked(AdColonyInterstitial ad) {
                super.onClicked(ad);
            }
            @Override
            public void onLeftApplication(AdColonyInterstitial ad) {
                super.onLeftApplication(ad);
            }
            @Override
            public void onExpiring(AdColonyInterstitial ad) {
                super.onExpiring(ad);
            }
        };
        // Optional Ad specific options to be sent with request
        interstitialAdOptions = new AdColonyAdOptions();
        AdColony.requestInterstitial(INTERSTITIAL_ZONE_ID, interstitialListener, interstitialAdOptions);
    }

displayInterstitialAd() method will display Interstitial ad on button click. If ad is not loaded or ad request not filled from server then it will display toast message.

public void displayInterstitialAd(View view) {
        if (interstitialAdColony!=null && isInterstitialLoaded) {
            interstitialAdColony.show();
            isInterstitialLoaded=false;
        }
        else {
            Toast.makeText(getApplicationContext(),"Interstitial Ad Is Not Loaded Yet or Request Not Filled",Toast.LENGTH_SHORT).show();
        }
    }

In initRewardedAd () method will request and load Reward Ad. rewardListener is defined to write your custom action on particular ad event. On onRequestFilled() method we will get AdColonyInterstitial Reward object from adcolony Ad Server. On onClosed() method we have again requested next Reward  ad. AdColony.setRewardListener() is defined to check result of reward video if reward is watched successfully then we will toast Reward Earned else Toast Reward Cancelled

private void initRewardedAd() {
        // Create and set a reward listener
        AdColony.setRewardListener(new AdColonyRewardListener() {
            @Override
            public void onReward(AdColonyReward reward) {
                // Query reward object for info here
                //here reward vid is seen by user
                //you can use this listener inside activity also
                if(reward.success()){
                    Toast.makeText(getApplicationContext(),"Reward Earned",Toast.LENGTH_SHORT).show();
                }
                else{
                    Toast.makeText(getApplicationContext(),"Reward Cancelled",Toast.LENGTH_SHORT).show();
                }
            }
        });
        // Set up listener for interstitial ad callbacks. You only need to implement the callbacks
        // that you care about. The only required callback is onRequestFilled, as this is the only
        // way to get an ad object.
        rewardListener = new AdColonyInterstitialListener() {
            @Override
            public void onRequestFilled(AdColonyInterstitial adReward) {
                // Ad passed back in request filled callback, ad can now be shown
                rewardAdColony = adReward;
                isRewardLoaded=true;
            }
            @Override
            public void onRequestNotFilled(AdColonyZone zone) {
            }
            @Override
            public void onOpened(AdColonyInterstitial ad) {
                super.onOpened(ad);
            }
            @Override
            public void onClosed(AdColonyInterstitial ad) {
                super.onClosed(ad);
                //request new reward on close
                AdColony.requestInterstitial(REWARD_ZONE_ID, rewardListener, rewardAdOptions);
            }
            @Override
            public void onClicked(AdColonyInterstitial ad) {
                super.onClicked(ad);
            }
            @Override
            public void onLeftApplication(AdColonyInterstitial ad) {
                super.onLeftApplication(ad);
            }
            @Override
            public void onExpiring(AdColonyInterstitial ad) {
                super.onExpiring(ad);
            }
        };
        // Ad specific options to be sent with request
        rewardAdOptions = new AdColonyAdOptions()
                .enableConfirmationDialog(false)
                .enableResultsDialog(false);
        AdColony.requestInterstitial(REWARD_ZONE_ID,rewardListener,rewardAdOptions);
    }

displayRewardVideoAd() method will show reward ad on button click. If ad is not loaded or ad request not filled from server then it will display toast message.

public void displayRewardVideoAd(View view) {
        if (rewardAdColony!=null && isRewardLoaded) {
            rewardAdColony.show();
            isRewardLoaded=false;
        }
        else {
            Toast.makeText(getApplicationContext(),"Reward Ad Is Not Loaded Yet or Request Not Filled",Toast.LENGTH_SHORT).show();
        }
    }

Whole Code

project level build.gradle

buildscript {
    repositories {
        jcenter()
        google()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url  "https://adcolony.bintray.com/AdColony"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app level build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.programtown.example"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

    implementation 'com.adcolony:sdk:4.1.4'
    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'

}

proguard-rules.pro file

# For communication with AdColony's WebView
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}

manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.programtown.example">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true"
        >
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.adcolony.sdk.AdColonyInterstitialActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            android:hardwareAccelerated="true"/>
        <activity android:name="com.adcolony.sdk.AdColonyAdViewActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            android:hardwareAccelerated="true"/>
    </application>

</manifest>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical"
    >

    <Button
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="Display InterstitialAd"
        android:onClick="displayInterstitialAd"
        ></Button>
    <Button
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="Display Reward Video Ad"
        android:onClick="displayRewardVideoAd"
        ></Button>
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="5"
        ></View>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical"
        android:gravity="center"
        android:id="@+id/colony"
        >

    </LinearLayout>

</LinearLayout>

MainActivity.java

package com.programtown.example;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.adcolony.sdk.AdColony;
import com.adcolony.sdk.AdColonyAdOptions;
import com.adcolony.sdk.AdColonyAdSize;
import com.adcolony.sdk.AdColonyAdView;
import com.adcolony.sdk.AdColonyAdViewListener;
import com.adcolony.sdk.AdColonyAppOptions;
import com.adcolony.sdk.AdColonyInterstitial;
import com.adcolony.sdk.AdColonyInterstitialListener;
import com.adcolony.sdk.AdColonyReward;
import com.adcolony.sdk.AdColonyRewardListener;
import com.adcolony.sdk.AdColonyZone;

public class MainActivity extends AppCompatActivity {

    private final static String APP_ID = "app7dd43d11ae344f74af";
    private final static String BANNER_ZONE_ID = "vz5ccc44c8de0c43f7a8";
    private final static String INTERSTITIAL_ZONE_ID = "vz614303d8339f4b95b4";
    private final static String REWARD_ZONE_ID = "vze9db182f005c424597";
    public final static String[] AD_UNIT_Zone_Ids = new String[] {BANNER_ZONE_ID,INTERSTITIAL_ZONE_ID,REWARD_ZONE_ID};

    private LinearLayout bannerConatiner;
    private AdColonyAdView bannerAdColony;

    private AdColonyInterstitial interstitialAdColony;
    private AdColonyInterstitialListener interstitialListener;
    private AdColonyAdOptions interstitialAdOptions;
    private static boolean isInterstitialLoaded;

    private AdColonyInterstitial rewardAdColony;
    private AdColonyInterstitialListener rewardListener;
    private AdColonyAdOptions rewardAdOptions;
    private static boolean isRewardLoaded;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initColonySdk();
        initBannerAd();
        initInterstitialAd();
        initRewardedAd();
    }

    private void initColonySdk(){
        // Construct optional app options object to be sent with configure
        AdColonyAppOptions appOptions = new AdColonyAppOptions().setKeepScreenOn(true);;
        // Configure AdColony in your launching Activity's onCreate() method so that cached ads can
        // be available as soon as possible.
        AdColony.configure(getApplication(), appOptions, APP_ID, AD_UNIT_Zone_Ids);
    }

    private void initBannerAd() {
        bannerConatiner = (LinearLayout)findViewById(R.id.colony);
        AdColonyAdViewListener bannerListener = new AdColonyAdViewListener() {
            @Override
            public void onRequestFilled(AdColonyAdView adColonyAdView) {
                //Remove previous ad view if present.
                if (bannerConatiner.getChildCount() > 0) {
                    bannerConatiner.removeView(bannerAdColony);
                }
                bannerConatiner.addView(adColonyAdView);
                bannerAdColony = adColonyAdView;
            }
            @Override
            public void onRequestNotFilled(AdColonyZone zone) {
                super.onRequestNotFilled(zone);
            }
            @Override
            public void onOpened(AdColonyAdView ad) {
                super.onOpened(ad);
            }
            @Override
            public void onClosed(AdColonyAdView ad) {
                super.onClosed(ad);
            }
            @Override
            public void onClicked(AdColonyAdView ad) {
                super.onClicked(ad);
            }
            @Override
            public void onLeftApplication(AdColonyAdView ad) {
                super.onLeftApplication(ad);
            }
        };
        // Optional Ad specific options to be sent with request
        AdColonyAdOptions adOptions = new AdColonyAdOptions();
        //Request Ad
        AdColony.requestAdView(BANNER_ZONE_ID, bannerListener, AdColonyAdSize.BANNER, adOptions);
    }

    private void initInterstitialAd() {
        // Set up listener for interstitial ad callbacks. You only need to implement the callbacks
        // that you care about. The only required callback is onRequestFilled, as this is the only
        // way to get an ad object.
        interstitialListener = new AdColonyInterstitialListener() {
            @Override
            public void onRequestFilled(AdColonyInterstitial adIn) {
                // Ad passed back in request filled callback, ad can now be shown
                interstitialAdColony = adIn;
                isInterstitialLoaded=true;
            }
            @Override
            public void onRequestNotFilled(AdColonyZone zone) {
                super.onRequestNotFilled(zone);
            }
            @Override
            public void onOpened(AdColonyInterstitial ad) {
                super.onOpened(ad);
            }
            @Override
            public void onClosed(AdColonyInterstitial ad) {
                super.onClosed(ad);
                //request new Interstitial Ad on close
                AdColony.requestInterstitial(INTERSTITIAL_ZONE_ID, interstitialListener, interstitialAdOptions);
            }
            @Override
            public void onClicked(AdColonyInterstitial ad) {
                super.onClicked(ad);
            }
            @Override
            public void onLeftApplication(AdColonyInterstitial ad) {
                super.onLeftApplication(ad);
            }
            @Override
            public void onExpiring(AdColonyInterstitial ad) {
                super.onExpiring(ad);
            }
        };
        // Optional Ad specific options to be sent with request
        interstitialAdOptions = new AdColonyAdOptions();
        AdColony.requestInterstitial(INTERSTITIAL_ZONE_ID, interstitialListener, interstitialAdOptions);
    }

    private void initRewardedAd() {
        // Create and set a reward listener
        AdColony.setRewardListener(new AdColonyRewardListener() {
            @Override
            public void onReward(AdColonyReward reward) {
                // Query reward object for info here
                //here reward vid is seen by user
                //you can use this listener inside activity also
                if(reward.success()){
                    Toast.makeText(getApplicationContext(),"Reward Earned",Toast.LENGTH_SHORT).show();
                }
                else{
                    Toast.makeText(getApplicationContext(),"Reward Cancelled",Toast.LENGTH_SHORT).show();
                }
            }
        });
        // Set up listener for interstitial ad callbacks. You only need to implement the callbacks
        // that you care about. The only required callback is onRequestFilled, as this is the only
        // way to get an ad object.
        rewardListener = new AdColonyInterstitialListener() {
            @Override
            public void onRequestFilled(AdColonyInterstitial adReward) {
                // Ad passed back in request filled callback, ad can now be shown
                rewardAdColony = adReward;
                isRewardLoaded=true;
            }
            @Override
            public void onRequestNotFilled(AdColonyZone zone) {
            }
            @Override
            public void onOpened(AdColonyInterstitial ad) {
                super.onOpened(ad);
            }
            @Override
            public void onClosed(AdColonyInterstitial ad) {
                super.onClosed(ad);
                //request new reward on close
                AdColony.requestInterstitial(REWARD_ZONE_ID, rewardListener, rewardAdOptions);
            }
            @Override
            public void onClicked(AdColonyInterstitial ad) {
                super.onClicked(ad);
            }
            @Override
            public void onLeftApplication(AdColonyInterstitial ad) {
                super.onLeftApplication(ad);
            }
            @Override
            public void onExpiring(AdColonyInterstitial ad) {
                super.onExpiring(ad);
            }
        };
        // Ad specific options to be sent with request
        rewardAdOptions = new AdColonyAdOptions()
                .enableConfirmationDialog(false)
                .enableResultsDialog(false);
        AdColony.requestInterstitial(REWARD_ZONE_ID,rewardListener,rewardAdOptions);
    }

    public void displayInterstitialAd(View view) {
        if (interstitialAdColony!=null && isInterstitialLoaded) {
            interstitialAdColony.show();
            isInterstitialLoaded=false;
        }
        else {
            Toast.makeText(getApplicationContext(),"Interstitial Ad Is Not Loaded Yet or Request Not Filled",Toast.LENGTH_SHORT).show();
        }
    }

    public void displayRewardVideoAd(View view) {
        if (rewardAdColony!=null && isRewardLoaded) {
            rewardAdColony.show();
            isRewardLoaded=false;
        }
        else {
            Toast.makeText(getApplicationContext(),"Reward Ad Is Not Loaded Yet or Request Not Filled",Toast.LENGTH_SHORT).show();
        }
    }
}

4) Run and test your application

Make sure you are connected to internet and then run app. After Running app at the bottom banner ad will be shown.

On Display InterstitialAd button click will show Interstitial Ad

On Display Reward Video Ad button click will show Reward Ad

Conclusion

In this post we have learned how to add AdColony Ads SDK in android application.

Please Subscribe Youtube| Like Facebook | Follow Twitter


Share Post
  •  
  •  
  •  
  • 2
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    2
    Shares

Leave a Reply

Your email address will not be published. Required fields are marked *