Introduction
The Cxense Ad SDK for Android enables the display 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 a minimum API level < 15.
-
SDK uses an auto-initialize method. You should remove old initialization code.
-
SDK uses Advertising ID instead of Android ID as the default user ID. You should migrate your data if you used the default user ID from the 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 higher.
You should use Gradle for building your app. SDK relies on Gradle features.
Quick Start
-
Change the 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 can configure the environment, network restrictions for when new ads are allowed to be fetched, and user geolocation (used for Geospatial Targeting):
|
Customization points
AdView extends the WebView component. That gives an opportunity to customize the behavior of AdView, like adding your own tricky cache mechanisms for web content caching or implementing interactions between your application and ad content.
If you want to change WebViewClient, you must extend our ImageCachingWebViewClient.
User ID
To enable audience-targeted ad campaigns in mobile apps, the Ad SDK provides a user-tracking feature. Each API call includes a special parameter named usi (full description: Search REST and JavaScript API), which designates the current user identifier.
By default, the Advertising ID serves as the user identifier in ad calls until a custom user ID overrides it.
Using custom User ID
|
Working with userconsent(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 it 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 for the 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 the public API, introducing a new way of AdView’s behavior customization. |
|
3.1.11 |
2016-06-25 |
Bug fixes and public documentation update. |
|
1.0.0 |
2015-05-20 |
First release of the Cxense Ad SDK for Android. |