Overview

The following document detaily shows that how to integrate Admost Android SDK and desired networks via gradle build setup. There are too many ad networks you may desire to add your current app. Integrating those ad networks to your application can achievable via gradle. Most of the ad networks are can be integrated by 1 line of code addition to your project's /app/src/build.gradle file and /build.gradle file. However some of them are requires more aditions to /app/src/main/AndroidManifest.xml and /app/src/proguard-rules.pro file.

Prerequisites

Android Version

Android 4.0 (Ice Cream Sandwich - API Version 14) or later.

IDE

You have to use Latest Android Studio build. You can download the latest Android Studio from here.

/app/src/main/AndroidManifest.xml, /app/src/build.gradle, /app/src/proguard-rules.pro and /build.gradle files may be required in the next parts. You can see where to find those files in project view structure.

Android Studio ~ Project view

  • .gradle
  • .idea
  • app
    • build
    • src
      • main
        • java
        • res
        • AndroidManifest.xml
      • build.gradleapp's gradle file
      • proguard-rules.pro
    • build
    • .gradle
    • build.gradleproject's gradle file
Folder/File Purpose
/app/src/main/AndroidManifest.xml This is your app's AndroidManifest.xml. We will just update inside of application tags.
/app/src/build.gradle This is your app's build.gradle file. We will just update inside of dependencies bracelets.
/app/src/proguard-rules.pro The proguard-rules.pro file is where you can add custom ProGuard rules.
/build.gradle This is project's build.gradle file. We will just update inside of repositories bracelets.

App ID & Zone ID

Application Id provided in Admost Mediation Dashboard. Zone Id(s) provided in Admost Mediation Dashboard.

Permissions

Some of the Ad networks requires additional permissions. You have to consider this while adding those ad networks in to your application. We handled those permissions in our SDK, you do not have to do anything but we are saying this to keep in mind.

Those permissions are listed below;


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

Setup

Ad-Networks

Please click + icon to add to list and - to remove from list. After finish selecting ad networks, continue with next step

Required Files

With your selections you are going to work with following files;

  • /build.gradle
  • /app/src/build.gradle

If you are using proguard you have to edit /app/src/proguard-rules.pro too.

Edit Files

Starting with Android 9.0 (API level 28), cleartext support is disabled by default. For applications targetSdkVersion higher than 27 must use the following manifest config for AdMost cleartext support.


<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:networkSecurityConfig="@xml/admost_network_security_config"
        ...>
        ...
    </application>
</manifest>
				

If you are using Admob SDK (com.google.android.gms:play-services-ads) with version 17.0.0 and higher, you must add your AdMob App ID to your Android Manifest file.


        <manifest>
          <application>
              <!-- Sample AdMob App ID: ca-app-pub-0000000000000000~0000000000 -->
              <meta-data
                  android:name="com.google.android.gms.ads.APPLICATION_ID"
                  android:value="[ADMOB_APP_ID]"/>
          </application>
        </manifest>
				

Proguard

Copy & paste following code snippet in to your /app/src/proguard-rules.pro file

			
# ADMOST
-keepattributes Exceptions, InnerClasses
-dontwarn admost.sdk.**
-keep class admost.sdk.** {*;}
-dontwarn admost.adserver.**
-keep class admost.adserver.** { *; }
-dontwarn com.google.android.exoplayer2.**
-keep class com.google.android.exoplayer2.**{ *;}
-keep class android.support.v4.app.DialogFragment { *; }
-keep class android.support.v4.util.LruCache { *; }


# VOLLEY
-keep class com.android.volley.** { *; }
-keep interface com.android.volley.** { *; }
-keep class org.apache.commons.logging.**

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# ADCOLONY
-dontwarn com.adcolony.**
-keep class com.adcolony.** { *; }
-keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; }
-keepclassmembers class com.adcolony.sdk.ADCNative** { *; }

# ADGEM
-keep class com.adgem.** { *; }
-dontwarn com.adgem.**

# ADMOB / ADX / GOOGLE
-keep class com.android.vending.billing.**
-keep public class com.google.android.gms.ads.** { public *; }
-keep public class com.google.ads.** { public *; }
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { public static final *** NULL; }
-keepnames class * implements android.os.Parcelable
-keepclassmembers class * implements android.os.Parcelable { public static final *** CREATOR; }
-keep @interface android.support.annotation.Keep
-keep @android.support.annotation.Keep class *
-keepclasseswithmembers class * { @android.support.annotation.Keep <fields>; }
-keepclasseswithmembers class * { @android.support.annotation.Keep <methods>; }
-keep @interface com.google.android.gms.common.annotation.KeepName
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * { @com.google.android.gms.common.annotation.KeepName *; }
-keep @interface com.google.android.gms.common.util.DynamiteApi
-keep public @com.google.android.gms.common.util.DynamiteApi class * { public <fields>; public <methods>; }
-keep public @com.google.android.gms.common.util.DynamiteApi class * { *; }
-keep class com.google.android.apps.common.proguard.UsedBy*
-keep @com.google.android.apps.common.proguard.UsedBy* class *
-keepclassmembers class * { @com.google.android.apps.common.proguard.UsedBy* *; }
-dontwarn android.security.NetworkSecurityPolicy
-dontwarn android.app.Notification

#ADTIMING
-dontwarn com.aiming.mdt.**.*
-dontoptimize
-dontskipnonpubliclibraryclasses
-keepattributes *Annotation*
#adt
-keep class com.aiming.mdt.**{ *; }
-keepattributes *Annotation*,InnerClasses
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
#R
-keepclassmembers class **.R$* {
public static <fields>;
}

# AMAZON
-dontwarn com.amazon.**
-keep class com.amazon.** { *; }
-dontwarn org.apache.http.**
-keepattributes *Annotation*

# APPLOVIN
-dontwarn com.applovin.**
-keep class com.applovin.** { *; }

# APPNEXT
-keep class com.appnext.** { *; }
-dontwarn com.appnext.**

# APPSAMURAI
-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <fields>;
}

# AVOCARROT - GLISPA
-keep class com.avocarrot.** { *; }
-dontwarn com.avocarrot.**
-keep class com.google.android.exoplayer2.SimpleExoPlayer
-dontwarn com.google.android.exoplayer2.SimpleExoPlayer

# CHARTBOOST
-dontwarn org.apache.http.**
-dontwarn com.chartboost.sdk.impl.**
-keep class com.chartboost.sdk.** { *; }
-keepattributes *Annotation*

# CRITEO
-dontwarn com.criteo.**
-keep class com.criteo.** { *; }

# DISPLAYIO
-keep class io.display.sdk.** { *; }
-dontwarn io.display.sdk.**
-keep class com.brandio.ads.** { *;}
-dontwarn com.brandio.ads.**

# FACEBOOK
-dontwarn com.facebook.ads.**
-dontnote com.facebook.ads.**
-keep class com.facebook.** { *; }
-keepattributes Signature
-keep class com.google.android.exoplayer2.** {*;}
-dontwarn com.google.android.exoplayer2.**

# FLURRY
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet, int); }
-keep class * extends java.util.ListResourceBundle { protected Object[][] getContents(); }
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { public static final *** NULL; }
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * { @com.google.android.gms.common.annotation.KeepName *; }
-keepnames class * implements android.os.Parcelable { public static final ** CREATOR; }

# FREECORP
-keep class com.fly.** { *; }
-dontwarn com.fly.**

# FYBER
-keep class com.fyber.** { *; }
-dontwarn com.fyber.**
-keep class com.fyber.mediation.MediationConfigProvider { public static *; }
-keep class com.fyber.mediation.MediationAdapterStarter { public static *; }
-keepclassmembers class com.fyber.ads.videos.mediation.** { void setValue(java.lang.String); }

# INMOBI
-keepattributes SourceFile,LineNumberTable
-keep class com.inmobi.** {*;}
-dontwarn com.inmobi.**
-keep public class com.google.android.gms.**
-dontwarn com.google.android.gms.**
-dontwarn com.squareup.picasso.**
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{public *;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info{public *;}
-keep class com.squareup.picasso.** {*;}
-dontwarn com.squareup.picasso.**
-dontwarn com.squareup.okhttp.**
-keep class com.moat.** {*;}
-dontwarn com.moat.**
-keep class com.integralads.avid.library.* {*;}


# INNERACTIVE
-dontwarn com.inneractive.api.ads.**
-keep class com.inneractive.api.ads.** {*;}
-keepclassmembers class com.inneractive.api.ads.** {*;}
-keepclassmembers class com.inneractive.api.ads.sdk.nativead.** {*;}
-keepattributes Signature
-keepattributes *Annotation*
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep class com.google.gson.examples.android.model.** { *; }
-keep class com.google.gson.Gson { *; }
-keep class com.google.gson.GsonBuilder { *; }
-keep class com.google.gson.FieldNamingStrategy { *; }

# IRONSOURCE
-dontwarn com.ironsource.**
-keep class com.ironsource.** { *; }
-keepclassmembers class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; }
-keep public class com.google.android.gms.ads.** { public *; }
-keep class com.ironsource.adapters.** { *; }
-dontwarn com.moat.**
-keep class com.moat.** { public protected private *; }

# LOOPME
-dontwarn com.loopme.**
-keep class com.loopme.** { *; }

# MEDIABRIX
-keep class com.mediabrix.** { *; }
-keep class com.moat.** { *; }
-keep class mdos.** { *; }
-dontwarn com.mediabrix.**
-dontwarn com.moat.**
-dontwarn mdos.**

# MILLENNIAL & NEXAGE
-keep class com.millennialmedia.** { *; }
-dontwarn com.millennialmedia.**

# MINTEGRAL
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.mintegral.** {*; }
-keep interface com.mintegral.** {*; }
-keep class android.support.v4.** { *; }
-dontwarn com.mintegral.**
-keep class **.R$* { public static final int mintegral*; }
-keep class com.alphab.** {*; }
-keep interface com.alphab.** {*; }

# MOBFOX
-dontwarn com.mobfox.**
-keep class com.mobfox.** { *; }
-keep class com.mobfox.adapter.** { *; }
-keep class com.mobfox.sdk.** { *; }

# MOPUB
-keepclassmembers class com.mopub.** { public *; }
-dontnote com.mopub.**
-dontwarn com.mopub.**
-keep public class com.mopub.**
-keep class com.mopub.mobileads.** { *; }
-keep class * extends com.mopub.mobileads.CustomEventBanner {}
-keep class * extends com.mopub.mobileads.CustomEventInterstitial {}
-keep class * extends com.mopub.nativeads.CustomEventNative {}
-keep class * extends com.mopub.nativeads.CustomEventRewardedAd {}
-keepclassmembers class ** { @com.mopub.common.util.ReflectionTarget *; }
-keepclassmembers class com.integralads.avid.library.mopub.** { public *; }
-keep public class com.integralads.avid.library.mopub.**
-keepclassmembers class com.moat.analytics.mobile.mpub.** { public *; }
-keep public class com.moat.analytics.mobile.mpub.**
-keep class com.google.android.gms.common.GooglePlayServicesUtil { *; }
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient { *; }
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { *; }
-keep class * extends java.util.ListResourceBundle { protected Object[][] getContents(); }
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { public static final *** NULL; }
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * { @com.google.android.gms.common.annotation.KeepName *; }
-keepnames class * implements android.os.Parcelable { public static final ** CREATOR; }
-keep public class android.webkit.JavascriptInterface {}

# NEND
-keep class net.nend.android.** { *; }
-dontwarn net.nend.android.**

# NATIVEX
-dontwarn com.nativex.**
-keep class com.nativex.** { *; }

# OUTBID
-dontwarn outbid.com.outbidsdk.**
-keep class outbid.com.outbidsdk.** { *; }

# PUBNATIVE
-keepattributes Signature
-keep class net.pubnative.** { *; }
-dontwarn net.pubnative.**
-keep class com.squareup.picasso.** { *; }
-dontwarn com.squareup.picasso.**

# REVMOB
-dontwarn rm.com.android.sdk.**
-keep class rm.com.android.sdk.** { public *; }

# RETROFIT
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}

# SMAATO
-dontwarn com.smaato.**
-keep class com.smaato.** { public *; }
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
    public static *** i(...);
}
-keep public class com.smaato.soma.internal.connector.OrmmaBridge { public *; }
-keepattributes *Annotation*
-dontwarn com.smaato.soma.SomaUnityPlugin*
-dontwarn com.millennialmedia**
-dontwarn com.facebook.**

# STARTAPP
-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile, LineNumberTable, *Annotation*, EnclosingMethod
-dontwarn android.webkit.JavascriptInterface
-keep class com.startapp.** { *; }
-dontwarn com.startapp.**

# TAPJOY
-keep class com.tapjoy.** {*;}
-keep class com.moat.** {*;}
-keepattributes JavascriptInterface
-keepattributes *Annotation*
-keep class * extends java.util.ListResourceBundle {protected Object[][] getContents();}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {public static final *** NULL;}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {@com.google.android.gms.common.annotation.KeepName *;}
-keepnames class * implements android.os.Parcelable {public static final ** CREATOR;}
-keep class com.google.android.gms.ads.identifier.** {*;}
-dontwarn com.tapjoy.**

# TAPPX
-keepattributes *Annotation*
-keepclassmembers class com.google.**.R$* { public static <fields>; }
-keep public class com.google.ads.** {*;}
-keep public class com.google.android.gms.** {*;}
-keep public class com.tappx.** { *; }
-dontwarn com.tappx.**

# UNITY
-dontwarn com.unity3d.**
-keep class com.unity3d.ads.** { *; }

# Vungle
-dontwarn com.vungle.**
-dontnote com.vungle.**
-keep class com.vungle.** { *; }
-dontwarn com.vungle.warren.error.VungleError$ErrorCode
-keep class com.moat.** { *; }
-dontwarn com.moat.**
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
-keepattributes Signature
-keepattributes InnerClasses
-keepattributes *Annotation*
-dontwarn sun.misc.**
-keep class com.google.gson.examples.android.model.** { *; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keep class com.google.android.gms.internal.** { *; }
-dontwarn com.google.android.gms.ads.identifier.**

-keepclassmembers enum com.vungle.warren.** { *; }
-dontwarn kotlin.Unit
-dontwarn retrofit2.-KotlinExtensions
-keepclassmembers,allowshrinking,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}
-dontwarn okhttp3.**
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-keepclassmembers class * extends com.vungle.warren.persistence.Memorable {
   public <init>(byte[]);
}


# YOUAPPI
-keep class com.google.gson.**{ *;}
-keep class com.google.android.gms.**{*;}
-keep class com.youappi.sdk.**{*;}
-keep interface com.youappi.sdk.**{*;}
-keep enum com.youappi.sdk.**{*;}
-keepclassmembers class * {
   @android.webkit.JavascriptInterface <methods>;
}

          

Usage

Admost Mediation library is a lean yet complete library that allows you to request and show ads. Basic integration steps are:

Init Ads

Initialize the Admost Mediation SDK in your application’s launcher Activity. This starts pre-caching and prepares the SDK to display ads.

AdMostConfiguration.Builder configuration = new AdMostConfiguration.Builder(this, < ADMOST_APP_ID >);
//GDPR COMPLIANCE
// Important: Please read the GDPR section below.
configuration.setSubjectToGDPR(false);
configuration.setUserConsent(true);

AdMost.getInstance().init(configuration.build(), new AdMostInitListener() {
	@Override
	public void onInitCompleted() {

	}

	@Override
	public void onInitFailed(int err) {

	}
});

GDPR

Once you have collected the user’s consent, you can pass it onto the SDK using the init configuration parameters shown above.

setUserConsent has a boolean parameter. If you have the user’s consent, set it true. If you do not have the user's consent, set it false.

setSubjectToGDPR has a boolean parameter. If you know the user is subject to GDPR, set it true. If you know the user is not subject to GDPR, set it false.

If you don’t pass the user’s consent or subjectToGDPR to the SDK, the default rules of Admost SDK will be applied.

IMPORTANT NOTE: We strongly recommend you to read our GDPR section.

/*
ZONE_ID : Your ZONE_ID defined on admost mediation panels.
TYPE    : The height of your banner, it may have 3 values;
            1. AdMostManager.getInstance().AD_BANNER (50dp)
            2. AdMostManager.getInstance().AD_LEADERBOARD (90dp)
            3. AdMostManager.getInstance().AD_MEDIUM_RECTANGLE (250dp)
BINDER  : You can use your own layout design for banners, if you leave BINDER value null, default design will be applied.
*/

BANNER = new AdMostView(ACTIVITY, < ZONE_ID >, < TYPE >, new AdMostViewListener() {
    @Override
    public void onReady(String network, int ecpm, View adView){
        // Ad is loaded and ready to be shown.
        // adView is the loaded banner's view and you need to attach it in your layout.
        // Sample usage ( https://github.com/admost/amrandroid/tree/master/sample/AMRSample )
    }

    @Override
    public void onFail(int errorCode) {
        // Ad is not loaded and can not be shown.
		// Warning: Attempting to load a new ad from the onFail() methods is strongly discouraged.
		// If you must load an ad from onFail() ensure to limit ad load retries to avoid continuous
		// failed ad requests in situations such as limited network connectivity.
    }

    @Override
    public void onClick(String network) {
        //Ad clicked
    }

}, < BINDER >);
// Add the following line to load an ad.
BANNER.load();

                

You can use tag functionality for banner zones. Tags will let you monitor the performance of the ads across different dimensions for the same zone. You can switch ads on and off for any specified tag whenever you want. Example usage is as follows;


// TAG can be any string value meaningful for you. You don't need to define it on AdMost dashboard before using.
// Just start using, it will be automatically detected
BANNER.load(TAG);
				

You have to call destroy(), pause() and resume() methods in the activity.

@Override
public void onResume() {
    super.onResume();
    BANNER.resume();
}

@Override
public void onPause() {
    super.onPause();
    BANNER.pause();
}


@Override
public void onDestroy() {
    super.onDestroy();
    BANNER.destroy();
}

Custom Native Design

If you want to create your own design for native ads, you have to create a binder object and pass it to AdMostView constructor as BINDER value. Example integration for binder creation is as follows;

int layout = layout.design_for_your_banner;
AdMostViewBinder BINDER = new AdMostViewBinder.Builder(layout)
	.titleId(R.id.ad_headline)
	.textId(R.id.ad_body)
	.callToActionId(R.id.ad_call_to_action)
	.iconImageId(R.id.ad_app_icon)
	.mainImageId(R.id.ad_image)
	.backImageId(R.id.ad_back)
	.attributionId(R.id.ad_attribution)
	.privacyIconId(R.id.ad_privacy) // it is only required for MOPUB and INMOBI native ads
	.isRoundedMode(false)
	.isFixed(false)
	.isCloseable(false)
	.build();

For privacy icon placement, you have to add the following ImageView to your custom layout with visibility GONE. It is suggested to add it to the right top corner of your layout with minimum width of 25dp;

<ImageView
        android:id="@+id/ad_privacy"
        android:layout_width="26dp"
        android:layout_height="26dp"
        android:paddingTop="2dp"
        android:paddingBottom="10dp"
        android:paddingLeft="10dp"
        android:paddingRight="2dp"
        android:src="@drawable/ad_privacy"
        android:layout_alignParentRight="true"
        android:visibility="gone" />

Interstitial

AdMostInterstitial INTERSTITIAL = new AdMostInterstitial(ACTIVITY, < ZONE_ID >, new AdMostAdListener() {
    @Override
    public void onDismiss(String message) {
        // It indicates that the interstitial ad is closed by clicking cross button/back button
    }
    @Override
    public void onFail(int errorCode) {
        // It indicates that the interstitial ad received no-fill response from all of its placements.
        // Therefore, the ad can not be shown.
        // Warning: Attempting to load a new ad from the onFail() methods is strongly discouraged.
        // If you must load an ad from onFail() ensure to limit ad load retries to avoid continuous
        // failed ad requests in situations such as limited network connectivity.

    }
    @Override
     public void onReady(String network, int ecpm) {
       // It indicates that the interstitial ad is loaded and ready to show.
    }
    @Override
    public void onShown(String network) {
        // It indicates that the loaded interstitial ad is shown to the user.
    }
    @Override
    public void onClicked(String s) {
        // It indicates that the interstitial ad is clicked.
    }
    @Override
    public void onComplete(String s) {
        // If you are using interstitial, this callback will not be triggered.
    }

});

You can use the following statement to load interstitial.

INTERSTITIAL.refreshAd(AUTO_SHOW);

AUTO_SHOW (boolean) : Set true, if you want to show the fullscreen ad as soon as it is ready. Otherwise, you need to call show() method manually.

INTERSTITIAL.show();

You can use tag functionality for interstitial zones. Tags will let you monitor the performance of the ads across different dimensions for the same zone. You can switch ads on and off for any specified tag whenever you want. Example usage is as follows;


// TAG can be any string value meaningful for you. You don't need to define it on AdMost dashboard before using.
// Just start using, it will be automatically detected
INTERSTITIAL.show(TAG);
				

You have to call destroy method when you are done with the interstitial.

INTERSTITIAL.destroy();

Rewarded

AdMostInterstitial VIDEO = new AdMostInterstitial(ACTIVITY, < ZONE_ID >, new AdMostAdListener() {
        @Override
         public void onReady(String network, int ecpm) {
            // It indicates that the rewarded video ad is loaded and ready to show.
        }
        @Override
        public void onFail(int errorCode) {
          // It indicates that the rewarded video ad received no-fill response from all of its placements.
          // Therefore, the ad can not be shown.
          // Warning: Attempting to load a new ad from the onFail() methods is strongly discouraged.
          // If you must load an ad from onFail() ensure to limit ad load retries to avoid continuous
          // failed ad requests in situations such as limited network connectivity.

        }
        @Override
        public void onDismiss(String message) {
          // It indicates that the rewarded video ad is closed by clicking cross button/back button.
          // It does not mean that the user deserves to receive a reward. You need to check whether onComplete(String network) callback is called or not
        }
        @Override
        public void onComplete(String network) {
          // It indicates that the user deserves to receive a reward. You may need to store this information in a variable and give a reward
          // to the user after onDismiss(String message) callback is called by showing some animations for instance.
          // Note: If onComplete(String network) callback is called for the ad, it is always called before onDismiss(String message) callback.
        }
        @Override
        public void onShown(String network) {
          // It indicates that the loaded rewarded video ad is shown to the user.(Note: It does not mean that the user deserves a reward)
          // It is immediately called after the loaded ad is shown to the user using VIDEO.show()
        }
        @Override
        public void onClicked(String s) {
            // It indicates that the video ad is clicked.
        }
    });
                

You can use the following statement to load rewarded video.

VIDEO.refreshAd(AUTO_SHOW);

AUTO_SHOW (boolean) : Set true, if you want to show the rewarded video ad as soon as it is ready. Otherwise, you need to call show() method manually.

VIDEO.show();

You can use tag functionality for rewarded video zones. Tags will let you monitor the performance of the ads across different dimensions for the same zone. You can switch ads on and off for any specified tag whenever you want. Example usage is as follows;


// TAG can be any string value meaningful for you. You don't need to define it on AdMost dashboard before using.
// Just start using, it will be automatically detected
VIDEO.show(TAG);
				

You have to call destroy method when you are done with the rewarded video.

VIDEO.destroy();

Offerwalls

OFFERWALL = new AdMostInterstitial(ACTIVITY, < ZONE_ID >, new AdMostAdListener() {
        @Override
        public void onReady(String network) {
            // Ad Loaded
        }
        @Override
        public void onFail(int errorCode) {
            // Ad Failed
        }
        @Override
        public void onDismiss(String message) {
            // Ad Dismiss
        }
        @Override
        public void onComplete(String network) {
            // Video Ad Completed
        }
        @Override
        public void onShown(String network) {
            //Ad Shown
        }
        @Override
        public void onClicked(String s) {
            //Ad Clicked
        }
});

You can use the following statement to load offerwall ad.

OFFERWALL.refreshAd(AUTO_SHOW);

AUTO_SHOW (boolean) : Set true, if you want to show the offerwall ad as soon as it is ready. Otherwise, you need to call show() method manually.

OFFERWALL.show();

You can use tag functionality for offerwall zones. Tags will let you monitor the performance of the ads across different dimensions for the same zone. You can switch ads on and off for any specified tag whenever you want. Example usage is as follows;


// TAG can be any string value meaningful for you. You don't need to define it on AdMost dashboard before using.
// Just start using, it will be automatically detected
OFFERWALL.show(TAG);
				

You have to call destroy method when you are done with the offerwall ad.

OFFERWALL.destroy();

Spending Virtual Currencies

AdMost.getInstance().spendVirtualCurrency(new AdMostVirtualCurrencyListener() {
    @Override
    public void onSuccess(String adNetwork, String currencyName, double value) {
        // User rewarded (This method can be triggered multiple times depends on Offerwall Zone)
    }

    @Override
    public void onError(String adNetwork, String error) {
        // Error
    }
});
                
    

Extras

DFP/Admob Mediation Integration

The Admost DFP Adapter lets publishers integrate Admost Mediation Router ads into applications with DFP or Admob Mediation set as main ad mediation layer.

In order to show Admost ads in DFP/Admob Mediation you should first follow Setup and init phases of Admost documentation. Then, you should follow dedicated steps of DFP or Admob Mediation to set Admost as an ad mediation source.

After adding Admost as an ad mediation source you should define class names for banner and interstitial ad custom events. Enter admost.sdk.dfp.AmrDfpCustomEventBanner and admost.sdk.dfp.AmrDfpCustomEventInt class names for banner and interstitial class names respectively. You must pass your Admost zone Id to custom event via Parameter field.

shadowed image
shadowed image

Now you can show Admost banner and interstitial ads via DFP or Admob Mediation.

You can check DFP banner and interstitial example in demo project; DFPIntegration.

Test Suite

You can use Test Suite to test your defined ad networks, you have to be a tester to use this function. To be a tester, you should add your GAID to Admost Dashboard Mediation > Manage Testers > New Tester. Tester activation takes 15 minutes. Use the following code to open test suite activity;


AdMost.getInstance().startTestSuite();
                

If you set user consent false, then you should add Admost generated id. You can find the id from log by searching 'admost'.
Example log:
/ADMOST: To enable AMR tester mode use this id : <201903210418A57D7ZBJSRTPY> on AMR dashboard Manage Testers page!

Screen Shot

android-test-suite screenshot

In App Purchase Tracking

The following call is used to track purchases with receipt validation:


AdMostIAPListener iabListener = new AdMostIAPListener() {
	//Successful Purchase
	@Override
	public void onValidationSuccess(String admostIapID) {}

	//Invalid purchase data..!
	@Override
	public void onValidationFail(String admostIapID, AdMostServerException e) {}

	//Exception occurred, will be tried again automatically..!
	@Override
	public void onException(String admostIapID) {}
};

String admostIapID = AdMost.getInstance().trackPurchase(purchaseData, dataSignature, jsonSkuDetail, iabListener, isDebug);
                

Explanation and code samples of parameters:

  • purchaseData (String) – a String in JSON format that contains details about the purchase order. It is returned by the operating system after you make the purchase call.
  • signature (String) – String containing the signature of the purchase data that the developer signed with their private key. It is returned by the operating system after you make the purchase call.
  • jsonSkuDetail (String) – a String in JSON Object format that contains product item details
  • iabListener (AdMostIAPListener) - You can add this callback to be informed about the result of your purchase request. null value is
  • isDebug (boolean) - Set true for test purchases.

//Handles an activity result that's part of the purchase flow in in-app billing
void onActivityResult(int requestCode, int resultCode, Intent data) {

    String dataSignature = data.getStringExtra(RESPONSE_INAPP_SIGNATURE);
    String purchaseData = data.getStringExtra(RESPONSE_INAPP_PURCHASE_DATA);

    if(resultCode == RESULT_OK){
        JSONObject purchasedProduct = new JSONObject(purchaseData);
        String purchasedItemId = purchasedProduct.getString("productId");
        for (String productData : responseList){
            JSONObject product = new JSONObject(productData);
        	String productId = product.getString("productId");
            if(productId.equals(purchasedItemId){
				AdMost.getInstance().trackPurchase(purchaseData, dataSignature, productData);
        	}
        }
    }
}
                

This is the way of getting responseList from Google


Bundle querySkus = new Bundle();
querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

ArrayList responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);
                        

For further information;

https://developer.android.com/google/play/billing/billing_reference.html#getSkuDetails

On subscription tracking, there is no difference in terms of client integration. However, for inquiry of application's periodic earnings, you have to create a service account on your Google api console project which is linked to your application and give financial data permission to this account on your google play developer console. While creating service account, you have to choose JSON as key type and send this JSON file to AdMost account manager.

Amazon Store In App Purchase Tracking

The following call is used to track amazon purchases with receipt validation:


AdMostIAPListener iabListener = new AdMostIAPListener() {
	//Successful Purchase
	@Override
	public void onValidationSuccess(String admostIapID) {}

	//Invalid purchase data..!
	@Override
	public void onValidationFail(String admostIapID, AdMostServerException e) {}

	//Exception occurred, will be tried again automatically..!
	@Override
	public void onException(String admostIapID) {}
};

String admostIapID = AdMost.getInstance().trackPurchaseAmazon(receiptJSON, purchaseResponseJSON, productJSON, iabListener, isDebug);
                

Explanation and code samples of parameters:

  • receiptJSON (JSONObject) – a JSON object. Retrieve that value from com.amazon.device.iap.model.PurchaseResponse OR com.amazon.device.iap.model.PurchaseUpdatesResponse like this:
    • purchaseResponse.getReceipt().toJSON()
    • purchaseUpdatesResponse.getReceipts().get(indexOfRelatedReceipt).toJSON()
  • purchaseResponseJSON (JSONObject) – a JSON object. Retrieve that value from com.amazon.device.iap.model.PurchaseResponse OR com.amazon.device.iap.model.PurchaseUpdatesResponse object like this:
    • purchaseResponse.toJSON()
    • purchaseUpdatesResponse.toJSON()
  • productJSON (JSONObject) – a JSON object. Retrieve that value from com.amazon.device.iap.model.Product object like this:
    • product.toJSON()
  • iabCallback (AdMostIAPCallback) - You can add this callback to be informed about the result of your purchase request. null value is
  • isDebug (boolean) - Set true for test purchases.

Setting Application User Id

You can use the following method to set application specific user id in Admost Analytics for enhanced tracking of your users. This information is also required for server to server callbacks. It is added to the callback URL to distinguish rewarded user.


AdMost.getInstance().setUserId("APPLICATION_USER_ID");

                

Setting Adjust User Id

You can use the following method to set adjust user id in Admost Analytics for enhanced tracking of your users.


AdMost.getInstance().setAdjustUserId("ADJUST_USER_ID");

                

Server to Server Callbacks

For rewarded video ads, you can use Server to Server Callbacks for rewarding users after successful completion of video ads. Please consult your business contact person for enabling it and setting required parameters like callback URL, request verification token and method.
To use this feature, only requirement on application side is setting your application user id as described here. You may also add new custom parameters to the callback URL by setting custom data to the rewarded video object(AdMostInterstitial) as shown in the sample code below. This method has to be called before showing ad.


Hashtable customData = new Hashtable<>();
customData.put("os", Build.VERSION.SDK_INT);
customData.put("ip", "172.12.1.23");
REWARDED.setSSVCustomData(customData);
                

GDPR Applicable Check

You can use the following method to check if the user is in a country which is subject to GDPR.


AdMost.getInstance().setGDPRListener(this, new AdMost.GDPRListener() {
	@Override
	public void isGDPRApplicable(boolean isGDPRApplicable) {

	}
});
                

Campaign Tracking

For tracking an ad campaign's performance, it is recommended to add Admost install referrer receiver into application tag of your AndroidManifest.xml for better tracking. If you are using other receiver libraries in your application like Google Analytics campaign tracking receiver, you can use the admost.install.referrer.[1-5] meta-data like below.


<manifest>
	<application>
		<receiver
			android:name="admost.sdk.base.InstallReferrerReceiver"
			android:exported="true">
			<intent-filter>
				<action android:name="com.android.vending.INSTALL_REFERRER" />
			</intent-filter>
			<meta-data android:name="admost.install.referrer.1" android:value="com.google.android.gms.analytics.CampaignTrackingReceiver" />
		</receiver>
	</application>
</manifest>

                

The Install Referrer API is exposed by the Google Play Store app on a device. Devices with a Google Play app version of 8.3.73 or later automatically have access to the API. Admost is using this functionality if available for better tracking. It is required to add the following dependency to your app gradle to enable this functionality.


dependencies {
    implementation 'com.android.installreferrer:installreferrer:1.0'
}