AdClient SDK For Android 4.3.0
AdClient SDK For Android 4.3.0
This manual provides a step-by-step guidance for the AdClient advertising integration to your Android applications.
User Manual
1. Preparation
1.1 Android Studio (or Gradle-based project)
5. Targeting Parameters
6. Debugging MRAID Ads
7. Location Updates
7.1 Requesting Location permissions
8. Consent
8.1 Preparation
9. Changelog
1. Preparation
Please see the s dk-sample-app project that contains an integration sample. Third-party libraries are located in the
libs directory.
//if you use InLocoMedia:
implementation 'com.inlocomedia.android:android-sdk-ads:4.3.19'
//if you use InMobi
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.gms:play-services-plus:16.0.0'
//if you use Facebook:
implementation 'com.facebook.android:audience-network-sdk:5.1.0'
//if you use MyTarget
implementation 'com.google.android.exoplayer:exoplayer-core:2.8.3'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.8.3'
//if you use Mobfox
implementation 'com.github.mobfox.MobFox-Android-SDK-Core:MobFox-Android-SDK-Core:3.6.4'
//vungle
implementation 'com.github.vungle:vungle-android-sdk:6.3.24'
}
● AdClient SDK requires metadata from Google Play Services. Also add your AdMob App ID to your app's
AndroidManifest.xml file by adding the <meta-data> tag shown below. You can find your App ID in the AdMob
UI. For android:value insert your own AdMob App ID in quotes, as shown below. Add the following to your
Manifest.xml f ile:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="[ADMOB_APP_ID]"
tools:replace="android:value"/>
Important: This step is required as of Google Mobile Ads SDK version 17.0.0. Failure to add this <
meta-data>
tag results in a crash with the message: "The Google Mobile Ads SDK was initialized incorrectly."
● Optional permissions:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
3. Obtaining Placement Key
The Placement Key is taken from Epom Apps dashboard or provided by your personal Epom Apps manager – it is an
essential identifier in Epom system and the only mandatory prerequisite to get things going with the AdClient SDK.
It is recommended to have the Placement Key on hand during the implementation.
Important: Use the parameters below when testing your app with our library, but don't forget to replace them
with the actual production values supplied to you before going live:
xmlns:app="http://schemas.android.com/apk/res-auto"
<com.adclient.android.sdk.nativeads.view.SmartBannerAdView
android:id="@+id/native_banner_ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:adPlacementKey="ec5086312cf4959dcc54fe8a8ad15401"
app:adServerUrl="https://appservestar.com/"
app:smartBannerAdSize="SMART_BANNER"
app:refreshInterval="30" />
Here are the parameters to add to your XML layout file:
Parameter D
efinition
refreshInterval * Refresh interval of 30 seconds will be applied if this parameter is omitted or the value is invalid.
For disabling refresh interval use 0 seconds.
Ad refresh rate in seconds: 30-90 seconds.
In order to ensure the best user experience it is highly recommended to disable all the external
refresh mechanisms.
Also refresh interval can be set in dashboard and has more weight than the parameter in the
code.
SMART_BANNER Screen width in portrait mode X Smart Banner for Phones and Tablets
32/50/90 dpi depending on screen
height
SMART_BANNER_FULL_WIDTH Screen width X 32/50/90 dpi Smart Banner for Phones and Tablets
depending on screen height
SMART_BANNER_PORTRAIT_WIDTH Screen width in portrait mode X 32 Smart Banner for Phones and Tablets
x32 dpi
SMART_BANNER_FULL_WIDTHx32 Screen width X 32 dpi Smart Banner for Phones and Tablets
SMART_BANNER_PORTRAIT_WIDTH Screen width in portrait mode X 50 Smart Banner for Phones and Tablets
x50 dpi
SMART_BANNER_FULL_WIDTHx50 Screen width X 50 dpi Smart Banner for Phones and Tablets
SMART_BANNER_PORTRAIT_WIDTH Screen width in portrait mode X 90 Smart Banner for Phones and Tablets
x90 dpi
SMART_BANNER_FULL_WIDTHx90 Screen width X 90 dpi Smart Banner for Phones and Tablets
For smart banner ads in the XML layout f ile, your sample application will be similar to this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/intro"
android:padding="4dip"
android:textSize="16sp" />
<com.adclient.android.sdk.nativeads.view.SmartBannerAdView
android:id="@+id/smart_banner_ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:adPlacementKey="ec5086312cf4959dcc54fe8a8ad15401"
app:adServerUrl="https://appservestar.com/"
app:custom="ch=urrrrr"
app:smartBannerAdSize="SMART_BANNER"
app:refreshInterval="30" />
</LinearLayout>
3. Next, in your A
ctivity or F
ragment code, declare an instance variable for your SmartBannerAdView and set up
SmartBannerAdViewListener for getting callbacks.
Method Definition
onBannerImpression(...) Fired when view was shown and impressions was sent
onBannerRefreshed(...) Fired when view was shown for refresh interval time and refreshed
In your Activity’s onCreate() or your Fragment’s onCreateView() method call load() to fetch and display the ad:
To manage the SmartBannerAdView lifecycle properly, use the following Activity methods: resume(), pause(),
destroy():
@Override
protected void onResume() {
super.onResume();
if (smartBannerAdView != null)
smartBannerAdView.resume();
}
@Override
protected void onPause() {
if (smartBannerAdView != null)
smartBannerAdView.pause();
super.onPause();
}
@Override
protected void onDestroy() {
if (smartBannerAdView != null)
smartBannerAdView.destroy();
super.onDestroy();
}
In order to ensure the best user experience it is highly recommended to disable all the external refresh
mechanisms.
Also refresh interval can be set in dashboard and has more weight than the parameter in the code.
smartBannerAdView.setConfiguration(params);
4. Set up A
dSize to SmartBannerAdView object:
smartBannerAdView.setAdSize(AdSize.SMART_BANNER);
5. Place created SmartBannerAdView anywhere within your existing layout:
LinearLayout myLayout = (LinearLayout) findViewById(R.id.main);
myLayout.addView(smartBannerAdView);
Set up S
martBannerAdViewListener for getting callbacks.
Method Definition
onBannerImpression(...) Fired when view was shown and impressions was sent
onBannerRefreshed(...) Fired when view was shown for refresh interval time and refreshed
For smart banner ads in your code, sample application will be:
To manage the SmartBannerAdView lifecycle properly, use the following Activity methods: resume(), pause(),
destroy():
@Override
protected void onResume() {
super.onResume();
if (smartBannerAdView != null)
smartBannerAdView.resume();
}
@Override
protected void onPause() {
if (smartBannerAdView != null)
smartBannerAdView.pause();
super.onPause();
}
@Override
protected void onDestroy() {
if (smartBannerAdView != null)
smartBannerAdView.destroy();
super.onDestroy();
}
4.2 Interstitial Ads
To display Interstitial ads anywhere in your app, use the AdClientInterstitial class programmatically:
public void onCreate(Bundle savedInstanceState) {
s uper.onCreate(savedInstanceState);
setContentView(R.layout.main);
final AdClientInterstitial interstitial = new AdClientInterstitial(this);
HashMap<ParamsType, Object> configuration = new HashMap<ParamsType, Object>();
configuration.put(ParamsType.AD_PLACEMENT_KEY, "0928de1630a1452b64eaab1813d3af64");
configuration.put(ParamsType.ADTYPE, AdType.INTERSTITIAL.toString());
configuration.put(ParamsType.AD_SERVER_URL,"http://appservestar.com/");
interstitial.setConfiguration(configuration);
interstitial.addClientAdListener(new ClientAdListener() {
@Override
public void onReceivedAd(AbstractAdClientView adClientView) {}
@Override
public void onFailedToReceiveAd(AbstractAdClientView adClientView) {}
@Override
public void onClickedAd(AbstractAdClientView adClientView) {}
@Override
public void onLoadingAd(AbstractAdClientView adClientView, String message) {
if (interstitial.isAdLoaded()) {
interstitial.show();
}
}
@Override
public void onClosedAd(AbstractAdClientView adClientView) {}
});
interstitial.load();
}
To manage the AdClientInterstitial lifecycle properly, use the following Activity methods: resume(),
pause(), destroy():
@Override
protected void onResume() {
super.onResume();
if (interstitial != null)
interstitial.resume();
}
@Override
protected void onPause() {
if (interstitial != null)
interstitial.pause();
super.onPause();
}
@Override
protected void onDestroy() {
if (interstitial != null)
interstitial.destroy();
super.onDestroy();
}
To display Rewarded ads anywhere in your app, use the AdClientRewarded class programmatically:
Native ads give you the control to design the perfect ad units for your app. With our Native ads, you can determine
the look and feel, size and location of your ads. You decide how the ads will be formatted, so they can seamlessly fit
in your application.
4.4.1 Preparation
You should create an XML layout for Native ads. It defines how an ad will be displayed in your app. It's up to you to
design the layout settings that will make the ad fit your app seamlessly.
Before integration, please check our best practices page for native ads
https://apps.epom.com/formats/native-best-practices.
Location: r es/layout/native_ad_layout.xml
<RelativeLayout ...>
<com.adclient.android.sdk.nativeads.view.AdClientIconView
android:id="@+id/native_ad_icon_image"
... />
<com.adclient.android.sdk.nativeads.view.AdClientMediaView
android:id="@+id/native_ad_media_view"
... />
<TextView android:id="@+id/native_ad_title_text"
... />
<TextView android:id="@+id/native_ad_subtitle_text"
... />
<TextView android:id="@+id/native_ad_description_text"
... />
<TextView android:id="@+id/native_ad_warning_text"
... />
<TextView android:id="@+id/native_ad_age_text"
android:padding="10dp"
... />
<RatingBar
android:id="@+id/native_ad_rating_bar"
android:isIndicator="true"
android:max="5"
.../>
<Button
android:id="@+id/native_ad_call_to_action_button"
.../>
<TextView android:id="@+id/native_ad_sponsored_text"
android:text="Sponsored"
... />
<com.adclient.android.sdk.nativeads.view.AdClientIconView
android:id="@+id/native_ad_privacy_information_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="10dp"
... />
</RelativeLayout>
Next, create an AdClientNativeAdBinder object. It should bind the XML layout and the ad content.
binder.bindView(AdClientNativeAdBinder.ViewType.ICON_VIEW, R.id.native_ad_icon_image);
binder.bindView(AdClientNativeAdBinder.ViewType.MEDIA_VIEW, R.id.native_ad_media_view);
binder.bindView(AdClientNativeAdBinder.ViewType.CALL_TO_ACTION_VIEW,
R.id.native_ad_call_to_action_button);
binder.bindView(AdClientNativeAdBinder.ViewType.SPONSORED_TEXT_VIEW, R.id.native_ad_sponsored_text);
binder.bindView(AdClientNativeAdBinder.ViewType.PRIVACY_ICON_VIEW,
R.id.native_ad_privacy_information_icon);
binder.bindView(AdClientNativeAdBinder.ViewType.RATING_VIEW, R.id.native_ad_rating_bar);
binder.bindView(AdClientNativeAdBinder.ViewType.WARNING_TEXT_VIEW, R.id.native_ad_warning_text);
binder.bindView(AdClientNativeAdBinder.ViewType.AGE_TEXT_VIEW, R.id.native_ad_age_text);
Optional: Specify the clickable subviews for better control (by default, all views are clickable):
List<Integer> clickItems = new ArrayList<>();
clickItems.add(R.id.call_to_action_button);
binder.setClickableItems(clickItems);
Create AdClientNativeAdRenderer instance for rendering Native Ad views after adding to your app content:
AdClientNativeAdRenderer renderer = new AdClientNativeAdRenderer(context, binder);
renderer.setShowImagesAutomatically(true); //by default enabled
ClientNativeAdImageListener clientNativeAdImageListener = new ClientNativeAdImageListener() {
@Override
public void onShowImageFailed(ImageView imageView, String uri, ImageDisplayError error) {
// error of loading image, you can try to load image by our image loading implementation
// or use your own or 3rd party library (Volley, UniversalImageLoader, Glide, Picasso etc)
AdClientNativeAd.displayImage(imageView, uri, this);
}
@Override
public void onNeedToShowImage(ImageView imageView, String uri) {
// called when automatic loading of images disabled by renderer.setShowImagesAutomatically(false)
// you can try to load image by our image loading implementation
// or use your own or 3rd party library (Volley, UniversalImageLoader, Glide, Picasso etc)
AdClientNativeAd.displayImage(imageView, uri, this);
}
@Override
public void onShowImageSuccess(ImageView imageView, String uri) {}
};
renderer.setClientNativeAdImageListener(clientNativeAdImageListener);
Create and set up AdClientNativeAd an AdClientNativeAd object instance (see example application class
NativeAdsSimpleActivity):
HashMap<ParamsType, Object> configuration = new HashMap<ParamsType,Object>();
configuration.put(ParamsType.AD_SERVER_URL,"http://appservestar.com/");
configuration.put(ParamsType.AD_PLACEMENT_KEY, "ec5086312cf4959dcc54fe8a8ad15401");
configuration.put(ParamsType.REFRESH_INTERVAL, 30);
AdClientNativeAd adClientNativeAd = new AdClientNativeAd(context, configuration, renderer);
Parameter Definition
refreshInterval ● Refresh interval of 0 seconds will be applied if this parameter is omitted or the value
is invalid.
● For disabling refresh interval use 0 seconds.
● Ad refresh rate in seconds: 30-90 seconds.
● In order to ensure the best user experience it is highly recommended to disable all
the external refresh mechanisms.
NOTE: R
efresh interval implementation of AdClientNativeAd works ONLY f or fully loaded and showed ads.
If you haven't received any ads and so they were not loaded – you should think out and make the mechanism
for the next load. The main point – is that refresh interval will work only after the ad is loaded and showed.
Set up ClientNativeAdListener for getting callbacks and load ad:
Method Definition
onImpressionAd(...) Fired when view was shown and impressions was sent
onRefreshedAd(...) Fired when view was shown for refresh interval time and refreshed
NOTE: F
or better performance you must use A
ctivity context for loading native ads.
For p
refetching ads in your A
pplication class see example application classes: SampleApplication,
NativeAdsFromApplicationLoaderActivity and NativeAdsFromApplicationActivity.
@Override
public void onLoadingAd(final AdClientNativeAd adClientNativeAd, final boolean isLoaded, String message,
boolean callbackFromUIThread) {
AdClientNativeAd.executeOnUiThread(context, new Runnable() {
@Override
public void run() {
Log.d("AdClientSdk", "onLoadingAd: loaded = " + isLoaded);
if (isLoaded) {
View nativeAdView = adClientNativeAd.getView(context);
adClientNativeAd.renderView(nativeAdView);
adClientNativeAd.registerImpressionsAndClicks(nativeAdView);
adsContainerLayout.addView(nativeAdView);
}
}
});
}
To manage the AdClientNativeAd lifecycle properly, use the following Activity methods: resume(), pause(),
destroy():
@Override
protected void onResume() {
super.onResume();
if (adClientNativeAd != null)
adClientNativeAd.resume();
}
@Override
protected void onPause() {
if (adClientNativeAd != null)
adClientNativeAd.pause();
super.onPause();
}
@Override
protected void onDestroy() {
if (adClientNativeAd != null) {
adClientNativeAd.destroy();
adClientNativeAd = null;
}
super.onDestroy();
}
To show the result, create rendered view and prepare it for impressions tracking.
Please, follow the order for calling methods:
View nativeAdView = adClientNativeAd.getView(activity);
adClientNativeAd.renderView(nativeAdView);
adClientNativeAd.registerImpressionsAndClicks(nativeAdView);
nativeAdContainerLinearLayout.removeAllViews();
nativeAdContainerLinearLayout.addView(nativeAdView);
Use a
dClientNativeAd.getViewByType(View view, AdClientNativeAdBinder.ViewType type) to customize
subview attributes on prepared view before (i.e.: typeface, color, size , etc.). For example:
TextView titleTextView = (TextView)adClientNativeAd.getViewByType(nativeAdView,
AdClientNativeAdBinder.ViewType.TITLE_TEXT_VIEW);
if(titleTextView!=null){
titleTextView.setTypeface(...);
titleTextView.setTextColor(...);
}
4.4.3 Native Media Ads
For displaying media ads, it is recommended to use the AdClientMediaView which can display both image and
video assets.
Create layout:
L
ocation: r es/layout/native_ad_layout.xml
<RelativeLayout ...>
<com.adclient.android.sdk.nativeads.view.AdClientMediaView
android:id="@+id/native_ad_media_view"
android:background="@null"
... />
<com.adclient.android.sdk.nativeads.view.AdClientIconView
android:id="@+id/native_ad_icon"
... />
<TextView android:id="@+id/native_ad_title_text"
... />
<TextView android:id="@+id/native_ad_subtitle_text"
... />
<TextView android:id="@+id/native_ad_description_text"
... />
<TextView android:id="@+id/native_ad_warning_text"
... />
<TextView android:id="@+id/native_ad_age_text"
android:padding="10dp"
... />
<RatingBar
android:id="@+id/native_ad_rating_bar"
android:isIndicator="true"
android:max="5" .../>
<Button
android:id="@+id/native_ad_call_to_action_button"
.../>
<TextView android:id="@+id/native_ad_sponsored_text"
android:text="Sponsored"
... />
<com.adclient.android.sdk.nativeads.view.AdClientIconView
android:id="@+id/native_ad_privacy_information_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="10dp"
android:background="@null"
... />
</RelativeLayout>
Next, create an AdClientNativeAdBinder object. It should bind the XML layout and the ad content.
AdClientNativeAdBinder binder = new AdClientNativeAdBinder(R.layout.native_ad_layout);
binder.bindView(AdClientNativeAdBinder.ViewType.TITLE_TEXT_VIEW, R.id.native_ad_title_text);
binder.bindView(AdClientNativeAdBinder.ViewType.SUBTITLE_TEXT_VIEW, R.id.native_ad_subtitle_text);
binder.bindView(AdClientNativeAdBinder.ViewType.DESCRIPTION_TEXT_VIEW, R.id.native_ad_description_text);
binder.bindView(AdClientNativeAdBinder.ViewType.ICON_VIEW, R.id.native_ad_icon);
binder.bindView(AdClientNativeAdBinder.ViewType.MEDIA_VIEW, R.id.native_ad_media_view);
binder.bindView(AdClientNativeAdBinder.ViewType.CALL_TO_ACTION_VIEW,
R.id.native_ad_call_to_action_button);
binder.bindView(AdClientNativeAdBinder.ViewType.SPONSORED_TEXT_VIEW, R.id.native_ad_sponsored_text);
binder.bindView(AdClientNativeAdBinder.ViewType.PRIVACY_ICON_VIEW,
R.id.native_ad_privacy_information_icon);
binder.bindView(AdClientNativeAdBinder.ViewType.RATING_VIEW, R.id.native_ad_rating_bar);
binder.bindView(AdClientNativeAdBinder.ViewType.WARNING_TEXT_VIEW, R.id.native_ad_warning_text);
binder.bindView(AdClientNativeAdBinder.ViewType.AGE_TEXT_VIEW, R.id.native_ad_age_text);
Create A
dClientNativeAdRenderer instance for rendering Native Ad views after adding to your app content:
AdClientNativeAdRenderer renderer = new AdClientNativeAdRenderer(context, binder);
renderer.setShowImagesAutomatically(true); //by default enabled
renderer.setClientNativeAdImageListener(clientNativeAdImageListener);
Create and set up AdClientNativeAd an AdClientNativeAd object instance
HashMap<ParamsType, Object> configuration = new HashMap<ParamsType,Object>();
configuration.put(ParamsType.AD_SERVER_URL,"http://appservestar.com/");
configuration.put(ParamsType.AD_PLACEMENT_KEY, "ec5086312cf4959dcc54fe8a8ad15401");
configuration.put(ParamsType.REFRESH_INTERVAL, 30);
AdClientNativeAd adClientNativeAd = new AdClientNativeAd(context, configuration, renderer);
Set up ClientNativeAdListener f or getting callbacks and load ad:
ClientNativeAdListener clientNativeAdListener = new ClientNativeAdListener() {
@Override
public void onImpressionAd(AdClientNativeAd adClientNativeAd, boolean callbackFromUIThread) {}
@Override
public void onFailedToReceiveAd(AdClientNativeAd adClientNativeAd, String message, boolean
callbackFromUIThread) {}
@Override
public void onClickedAd(AdClientNativeAd adClientNativeAd, boolean callbackFromUIThread) {}
@Override
public void onLoadingAd(final AdClientNativeAd adClientNativeAd, final boolean isLoaded, String
message, boolean callbackFromUIThread) {}
@Override
public void onRefreshedAd(AdClientNativeAd adClientNativeAd, String message, boolean
callbackFromUIThread){}
}
adClientNativeAd.setClientNativeAdListener(clientNativeAdListener);
adClientNativeAd.load();
To manage the AdClientNativeAd l ifecycle p
roperly, use the following Activity methods: r
esume(), pause(),
destroy():
@Override
protected void onResume() {
super.onResume();
if (adClientNativeAd != null)
adClientNativeAd.resume();
}
@Override
protected void onPause() {
if (adClientNativeAd != null)
adClientNativeAd.pause();
super.onPause();
}
@Override
protected void onDestroy() {
if (adClientNativeAd != null) {
adClientNativeAd.destroy();
adClientNativeAd = null;
}
super.onDestroy();
}
To show the result, create rendered view and prepare it for impressions tracking.
Please, follow the order for calling methods:
View nativeAdView = adClientNativeAd.getView(context);
adClientNativeAd.renderView(nativeAdView);
adClientNativeAd.registerImpressionsAndClicks(nativeAdView);
nativeAdContainerLinearLayout.removeAllViews();
nativeAdContainerLinearLayout.addView(nativeAdView);
To show more than one native ad you can use your own logic with a preloaded collection of AdClientNativeAd
objects or our implementation of basic adapters from the SDK-sample-app:
Important: A
fter you finish the integration, please provide a mockup with native ads in your app to an Epom
Apps Manager or forward it to [email protected].
4.5 Banner Ads
Parameter Definition
Parameter Definition
refreshInterval Refresh interval of 30 seconds will be applied if this parameter is omitted or the value is
invalid.
For disabling refresh interval use 0 seconds.
Ad refresh rate in seconds: 30-90 seconds.
Not used for Interstitial ads.
In order to ensure the best user experience it is highly recommended to disable all the
external refresh mechanisms.
app:viewBackground = "magenta"
Defaults value: black
2. Insert a reference to the attrs.xml file in your layout element: add the x
mlns line that includes your package
name specified in AndroidManifest.xml. I.e., for the c
om.adclient.sample p
ackage the line will be:
xmlns:app = "http://schemas.android.com/apk/res/com.adclient.sample"
3. Add A
dClientView to the layout:
B
anner:
<com.adclient.android.sdk.view.AdClientView
android:id="@+id/adClientView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:adPlacementKey="58296e9c9472044364aa6770d8409ede"
app:refreshInterval="30"
app:adType="BANNER_320X50"
app:adServerUrl ="http://appservestar.com/" />
For banner ads in the XML layout f ile, your sample application will be similar to this:
<?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/com.adclient.sample"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/intro"
android:textSize="16sp" />
<com.adclient.android.sdk.view.AdClientView
android:id="@+id/adClientView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:adPlacementKey="58296e9c9472044364aa6770d8409ede"
app:adServerUrl ="http://appservestar.com/"
app:refreshInterval="30"
app:adType="BANNER_320X50" />
<Button android:text="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
4. Next, in your A
ctivity or F
ragment code, declare an instance variable for your AdClientView. In your Activity’s
onCreate() or your Fragment’s onCreateView() method call load() to fetch and display the ad:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final AdClientView adClientView = findViewById(R.id.adClientView);
adClientView.addClientAdListener(new ClientAdListener() {
@Override
public void onReceivedAd(AbstractAdClientView adClientView) {}
@Override
public void onFailedToReceiveAd(AbstractAdClientView adClientView) {}
@Override
public void onClickedAd(AbstractAdClientView adClientView) {}
@Override
public void onLoadingAd(AbstractAdClientView adClientView, String message) {}
@Override
public void onClosedAd(AbstractAdClientView adClientView) {}
});
adClientView.load();
}
To manage the AdClienView lifecycle properly, use the following Activity methods: resume(), pause(),
destroy():
@Override
protected void onResume() {
super.onResume();
if (adClientView != null)
adClientView.resume();
}
@Override
protected void onPause() {
if (adClientView != null)
adClientView.pause();
super.onPause();
}
@Override
protected void onDestroy() {
if (adClientView != null)
adClientView.destroy();
super.onDestroy();
}
2. Create A
dClientView object using one of the following constructors:
dClientView(Context context);
public A
public A dClientView(Context context, AttributeSet attrs);
public A dClientView(Context context, AttributeSet attrs, int defStyle);
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
adClientView.load();
}
});
}
To manage the AdClienView lifecycle properly, use the following Activity methods: r
esume(), pause(),
destroy():
@Override
protected void onResume() {
super.onResume();
if (adClientView != null)
adClientView.resume();
}
@Override
protected void onPause() {
if (adClientView != null)
adClientView.pause();
super.onPause();
}
@Override
protected void onDestroy() {
if (adClientView != null)
adClientView.destroy();
super.onDestroy();
}
5. Targeting Parameters
To optimize the advertising performance it is possible to pass the targeting parameters to the ad request
configurations. For example:
Birthday If your app already knows a user's Birthday, it can provide that information for targeting purposes.
Birth year If your app already knows a user's Birth Year, it can provide that information for targeting purposes.
Gender If your app already knows a user's Gender, it can provide that information for targeting purposes.
Language If your app already knows a user's Language, it can provide that information targeting purposes.
Location If your app already knows a user's Location, it can provide that information targeting purposes.
City If your app already knows a user's City, it can provide that information targeting purposes.
Region If your app already knows a user's Language, it can provide that information targeting purposes.
Keywords Tags set by the app developer that describe the type of content (e.g.: cars, news, restaurants, new
york, etc.)
Categories Tags set by the app developer that describe the type of app categories (e.g., M
usic, Sport...)
Interests If your app already knows a user's interests, it can provide that information targeting purposes (e.g.,
music, video, photo...).
Search queries A search term or keywords entered by the user (e.g., restaurant New York). For example, if there is a
search bar in your app, when end users search for restaurant, you can pass the query string to
search terms.
Child-directed For purposes of the Children's Online Privacy Protection Act (COPPA), there is a setting called "tag
setting for child-directed treatment"
With AdClient SDK for Android it is possible to debug custom MRAID-powered ads. Use mraid.logEntry(message)
at any place in your Rich Media Banner to pass the information to Android logging facility.
7. Location Updates
AdClient SDK for Android allows controling location updates via API by retrieving the information from users'
devices.
Use the L
ocationWatcher interface to access location update management methods:
● watch() – ensures that coordinates of the user's device are sent along with every ad request; boolean value.
● unWatch() – removes location listener, no coordinates will be requested or sent with the ad requests;
boolean value.
These methods are called automatically when the visibility of the application window changes, so they can not be
used to stop location updates on the permanent basis. To change the location update methods and intervals
permanently use:
For instance, to set location update interval – which is one hour by default – to 5 seconds for the network provider,
and to 10 minutes for the GPS provider:
locationProviderMap.get(LocationManager.NETWORK_PROVIDER).setMinTime(5000);
locationProviderMap.get(LocationManager.GPS_PROVIDER).setMinTime(600000);
Under the Google EU User Consent Policy, you must make certain disclosures to your users in the European
Economic Area (EEA) and obtain their consent to use cookies or other local storage, where legally required, and to
use personal data (such as AdID) to serve ads. This policy reflects the requirements of the EU ePrivacy Directive and
the General Data Protection Regulation (GDPR).
8.1 Preparation
Place the EpomApps Consent library AAR file (epomapps-android-consent-*.aar) to the libraries' storage in your
project (see build.gradle file in the sdk-sample-app). The following code should be added to the build.gradle file:
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
implementation 'com.google.android.ads.consent:consent-library:1.0.7'
}
It is recommended that you determine the status of a user's consent at every app launch. To do this, call
requestConsentStatusUpdate() on an instance of C
onsentInformationManager:
If the consent information is successfully updated, the updated consent status is provided via the
onConsentStateUpdated() method of the O
nConsentStatusUpdateListener.
The returned consent status may have the values listed below:
ConsentStatus Definition
ConsentStatus.UNKNOWN The user has neither granted nor declined consent for personalized or
non-personalized ads.
The returned location status may have the values listed below:
Location Status Definition
LocationStatus.NOT_IN_EEA The user is not located in the European Economic Area and consent is not
required under the E U User Consent Policy
LocationStatus.IN_EEA The user is located in the European Economic Area and consent is
required under the E U User Consent Policy
8.3 Collect Consent
The EpomApps rendered consent form is a full-screen configurable form that displays over your app content.
Consent form is configured and displayed using the C
onsentForm class. The following code demonstrates how to
build a C
onsentForm with all consent options:
ConsentForm consentForm = ConsentForm.createBuilder(this)
.withListener(new ConsentFormListener() {
@Override
public void onConsentFormLoaded() {
// Consent form loaded successfully.
}
@Override
public void onConsentFormError(String reason) {
// Consent form error.
}
@Override
public void onConsentFormOpened() {
// Consent form was displayed.
}
@Override
public void onConsentFormClosed(ConsentStatus consentStatus, Boolean userPrefersAdFree) {
// Consent form was closed.
}
})
.withPayOption()
.build();
consentForm.load();
The methods above prepare the EpomApps rendered consent form with the following options:
withListener()
Registers a listener for the ConsentForm. Each of the overridable methods in ConsentFormListener corresponds to
an event in the lifecycle of the consent form.
Method Description
onConsentFormClosed The consent form was closed. The parameters of the method provides the following
information:
● consentStatus is a C
onsentStatus value that describes the updated consent
status of the user.
● userPrefersAdFree has a value of true when the user chose to use a paid
version of the app instead of viewing ads.
onConsentFormError The consent form failed to load. The reason parameter provides a description of the
error.
withPayOption()
Indicates that the consent form should show an ad-free app option. U
se a paid version of the app instead of viewing
ads and collecting user data
Once you have created a ConsentForm object, load the consent form by invoking the load() method of
ConsentForm, as shown below:
consentForm.load();
To present the user with the consent form, call show() on an instance of C
onsentForm, as demonstrated below:
consentForm.show();
After the user selects an option and closes the form, the EpomApps consent SDK saves the user's choice and fires
the onConsentFormClosed event.
NOTE: I t is important that the user is able to change or revoke the consent they have provided at any time.
To allow users to update their consent, simply repeat the steps outlined in the Collect consent section when the
user chooses to update their consent status.
9. Changelog
Version 4.3.0
● Updated Vungle to 6.3.24
● Added support for application networks
● Changed documentation
● Bug fix
Bug fix
Version 4.2.1
● Changed documentation
● Added test key for Rewarded Video
● Fixed Sample Application
● Bug fix
Version 4.2.0
● Fixed smart banner for landscape mode
● Updated networks
1. Adcolony 3.3.7
2. Admob 17.1.2
3. Applovin 9.1.3
4. Appnext 2.4.4.472
5. Facebook 5.1.0
6. Chartboost 11.2.0
7. Inmobi 7.2.1
8. Inlocomedia 4.3.10
9. Mintegral 9.4.0
10. Mopub 5.4.1
11. Mytarget 5.4.1
12. StartApp 3.9.0
13. Tapjoy 12.2.0
14. Tappx 3.1.3
15. UnityAds 3.0.0
● Added new network Mobfox-3.6.4
● Updatedc gdpr sdk
● Changed version of play services:
○ ads 17.1.2
○ basement 16.1.0
○ location 16.0.0
○ plus 16.0.0
● upgraded version:
○ cmpileSdkVersion 28
○ buildToolsVersion '28.0.3'
Version 4.1.0
● Native Ads
➔ Changed AdClientNativeAdRenderer constructor signature from
AdClientNativeAdRenderer(binder) t o A dClientNativeAdRenderer(context, binder)
➔ Changed initialization of AdClientNative instance:
from:
AdClientNativeAd adClientNativeAd = new AdClientNativeAd(context);
adClientNativeAd.setConfiguration(context, configuration);
adClientNativeAd.setRenderer(renderer);
to:
AdClientNativeAd adClientNativeAd = new AdClientNativeAd(context, configuration,
renderer);
➔ Changed AdClientNative methods load() and r esume() signature (removed Context parameter)
➔ Updated ad view rendering:
from:
View nativeAdView = adClientNativeAd.getView(context);
adClientNativeAd.renderView(nativeAdView);
adClientNativeAd.prepareView(nativeAdView);
to:
View nativeAdView = adClientNativeAd.getView(context);
adClientNativeAd.renderView(nativeAdView);
adClientNativeAd.registerImpressionsAndClicks(nativeAdView);
➔ AdClientMediaView moved to c om.adclient.android.sdk.nativeads.view package.
➔ Created AdClientIconView class for showing icon & privacy icon assets instead of ImageView.
➔ Removed AdClientNativeAdBinder.ViewType.MAIN_IMAGE_VIEW (use
AdClientNativeAdBinder.ViewType.MEDIA_VIEW)
➔ Renamed A dClientNativeAdBinder.ViewType.ICON_IMAGE_VIEW to
AdClientNativeAdBinder.ViewType.ICON_VIEW
➔ Renamed A dClientNativeAdBinder.ViewType.PRIVACY_ICON_IMAGE_VIEW to
AdClientNativeAdBinder.ViewType.PRIVACY_ICON_VIEW
➔ Improved ads rendering mechanism
➔ Improved impressions and clicks handling
● SmartBanner ads
➔ Improved ads rendering mechanism
➔ Improved impressions and clicks handling
➔ Changed SmartBannerAdView l oad() and resume() methods signature of (removed Context
parameter)
● Bug fixes.