Introduction
The Cxense Ad SDK for Android enables displaying of ads from the Cxense Ad service in Android applications.
Migration Notes
Version 3.2.1 simplifies SDK addition for your project.
-
SDK is available in one popular Maven repository now. See section "Add library using Gradle" in Quick Start
-
SDK JavaDoc is available online now. See here
Version 3.2.0 has many breaking changes in API and SDK structure. Please see JavaDoc and Quick Start
-
SDK requires API level 15 as minimum. Use previous version 3.1.18, if your application needs minimum API level < 15.
-
SDK uses auto initialize method. You should remove old initialization code.
-
SDK uses Advertising ID instead Android ID as default user id. You should migrate your data, if you used default user id from SDK before.
-
SDK uses some new third-party dependencies:
-
Retrofit 2, OkHttp 3, Jackson
-
Google Play Services Ads 7.0 (only for AAID).
-
Requirements
SDK requires at minimum Java 8 and Android 4.0.3 (API level 15) or upper.
You should use Gradle for building your app. SDK relies on Gradle features.
Quick Start
-
Change gradle plugin version in root build.gradle (We need 3.0 or newer). Find this code:
buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' // and change this line } } -
Add SDK to project using Gradle
-
Add in your root build.gradle at the end of repositories:
allprojects { repositories { ... maven { url 'https://jitpack.io' } } } -
Add in app build.gradle
android { ... packagingOptions { exclude 'META-INF/LICENSE' } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { ... compile "com.cxpublic.cx-android-sdk:cx-ad:VERSION" }
-
-
Add AdView:
-
Using XML (Example)
<FrameLayout 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="com.example.cxensead.BannerFragment"> <com.cxense.ad.AdView android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="match_parent" app:adSpace="YOUR_AD_SPACE_ID" app:refreshRate="60" app:autoStart="true"/> </FrameLayout> -
Using code
AdView adView = new AdView(context); adView.setAdSpace("YOUR_AD_SPACE_ID"); ... adView.start(); ... // Set refresh rate (60 seconds by default), to disable automatic refresh handling set the refresh rate to 0 adView.setRefreshRate(refreshRate, TimeUnit.SECONDS); // if you disable refresh timeout, use this for manually refresh view adView.refresh();
-
Additional Configuration
In addition to the above you canconfigureenvironment, network restrictions for when new ads are allowed to be fetched and user geolocation (used for Geospatial Targeting):
|
Customization points
AdView extends WebView component. That gives an opportunity tocustomizebehaviorofAdView like adding own tricky cache mechanisms for web content caching or implementing interactions between your application and ad’s content.
If you want to change WebViewClient, you must extend our ImageCachingWebViewClient.
User ID
To make possible to use audience targeted ad campaigns in mobile applications, Ad SDK provides user tracking feature. You can see that among other parameters each API call has specialparametercalled "usi" (full description is available here: Search REST and JavaScript API). It designates current user identifier.
Advertising ID is used by default as user identifier in ad calls until it will be overridden by custom user id.
Using custom User ID
|
Working with userconsest(GDPR)
|
Release Notes
|
Version |
Release Date |
Notes |
|---|---|---|
|
3.4.0 |
2018-05-23 |
Added user consent options |
|
3.3.1 |
2017-09-28 |
User tracking was added. That makes possible to use audience targeting. |
|
3.3.0 |
2017-08-14 |
Multiple internal changes |
|
3.2.2 |
2017-06-21 |
Fixed bug in SDK initialization |
|
3.2.1 |
2017-06-09 |
Added support of Maven dependency management system. |
|
3.2.0 |
2017-06-06 |
Minimum SDK was increased from 11 to 15.
|
|
3.1.16 |
2017-03-24 |
Internal improvements. AdView’s underlying WebView was added to public APIintroducingnewwayof AdView’s behavior customization. |
|
3.1.11 |
2016-06-25 |
Bugfixes and public documentation update. |
|
1.0.0 |
2015-05-20 |
First release of the Cxense Ad SDK for Android. |