Download AdClient SDK for Android

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
 AdClient SDK for Android User Manual This manual provides a simple step by step guidance for a quick and painless integration of ​
AdClient​
advertising into your applications. 1. Preparation Place the AdClient SDK JAR file (adclient­sdk­for­android­*.jar) in your build path similar to any other external jar that you might already have included into your project. This is most likely to be found ​
under the "libs" subdirectory of your project's root directory. For Eclipse IDE projects steps are the following: • Go to the Properties tab of your project. • Select "Java Build Path" from the panel on the left side. • Select "Libraries" tab in the main window. • Click "Add External JARs " button. • Select the JAR (adclient­sdk­for­android­*.jar). • To add the SDK to your Android project, Click "OK". • Go to “Order and Export” tab from the main window • Check the adclient­sdk­for­android­*.jar. AdClient SDK has following dependencies: • Android Support v4 library Add advertising network specific sdk jars as well to ensure ability to retrieve ads from the networks that you are planning to use as ad sources. 2. Setting permissions in Manifest.xml file Given table represents vendor specific info for adding into Your AndroidManifest.xml configuration along with minimal required API level and highest version of vendor sdk which AdClient SDK has been tested against: Vendor Minimal API Level Permissions Tested Version Required Activities AdMob 9 mandatory: 1.INTERNET 2.ACCESS_NETWORK_STATE Google Play <activity android:name="com.google.an
Services droid.gms.ads.AdActivity" 5.0.77 android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize"/> <meta­data android:name="com.google.an
droid.gms.version" android:value="@integer/googl
e_play_services_version" /> InMobi 8 mandatory: 1.INTERNET 2.ACCESS_NETWORK_STATE optional: 1.ACCESS_COARSE_LOCATION 2.ACCESS_FINE_LOCATION 3.ACCESS_WIFI_STATE 4.5.0 <activity android:name="com.inmobi.an
droidsdk.IMBrowserActivity" android:configChanges="keybo
ardHidden|orientation|keyboar
d|smallestScreenSize|screenSiz
e" android:theme="@android:styl
4.CHANGE_WIFI_STATE 5.READ_LOGS 6.VIBRATE 7.RECORD_AUDIO 8.WRITE_EXTERNAL_STORAGE 9.READ_CALENDAR 10.WRITE_CALENDAR 11.com.google.android.gms.per
mission.ACTIVITY_RECOGNITIO
N Smaato e/Theme.Translucent.NoTitleBa
r" /> <meta­data android:name="com.google.an
droid.gms.version" android:value="@integer/googl
e_play_services_version" /> <service android:name="com.inmobi.co
mmons.internal.ActivityRecogni
tionManager" android:enabled="true" /> 5 mandatory: 1.INTERNET optional: 1.READ_PHONE_STATE 2.ACCESS_NETWORK_STATE 3.ACCESS_COARSE_LOCATION 4.ACCESS_FINE_LOCATION 5.WRITE_EXTERNAL_STORAGE 6.​
READ_CALENDAR 7.WRITE_CALENDAR 8.GET_ACCOUNTS 4.3.2 <activity android:name="com.smaato.so
ma.interstitial.InterstitialActivity
" /> If you are using Google Play Services SDK: <meta­data android:name="com.google.an
droid.gms.version" android:value="@integer/googl
e_play_services_version"/> InnerActive 8 mandatory: 1.INTERNET 2.ACCESS_NETWORK_STATE optional: 1.READ_PHONE_STATE 2.ACCESS_COARSE_LOCATION 3.ACCESS_FINE_LOCATION 4.WRITE_EXTERNAL_STORAGE 5.0.2 <activity android:name="com.inneractiv
e.api.ads.sdk.InneractiveIntern
alBrowserActivity" android:configChanges="keybo
ardHidden|orientation|screenSi
ze"/> <activity android:name="com.inneractiv
e.api.ads.sdk.InneractiveInterst
itialAdActivity" android:configChanges="keybo
ardHidden|orientation|screenSi
ze"/> <activity android:name="com.inneractiv
e.api.ads.sdk.InneractiveRichM
ediaVideoPlayerActivity" android:configChanges="keybo
ardHidden|orientation"/> MillenialMe
dia mandatory: 1.INTERNET 2.WRITE_EXTERNAL_STORAGE 3.READ_PHONE_STATE 4.ACCESS_NETWORK_STATE 4.5.1 <activity android:name=”com.millennial
media.android.MMActivity” android:configChanges="keybo
ardHidden|orientation|keyboar
d" android:theme="@android:styl
e/Theme.Translucent.NoTitleBa
r"/> <activity 3 android:name=”com.millennial
media.android.VideoPlayer” android:configChanges="keybo
ardHidden|orientation|keyboar
d" /> Yoc 5 Performanc
e mandatory: 1.INTERNET 2.ACCESS_NETWORK_STATE optional: 1.ACCESS_FINE_LOCATION 2.READ_PHONE_STATE 3.WRITE_CALENDAR 4.CALL_PHONE"> 5.SEND_SMS 6.WRITE_EXTERNAL_STORAGE 3.0.2 ­ TapIt 4 mandatory: 1.INTERNET 2.READ_PHONE_STATE 3.ACCESS_NETWORK_STATE optional: 1.ACCESS_FINE_LOCATION 2.ACCESS_COARSE_LOCATION 3.WRITE_EXTERNAL_STORAGE 1.0 <activity android:name="com.tapit.advie
w.ormma.util.OrmmaActionHan
dler"/> <activity android:name="com.tapit.advie
w.AdActivity" android:configChanges="keybo
ard|keyboardHidden|orientatio
n"/> Wap Start 7 mandatory: 1.INTERNET optional: 1.ACCESS_FINE_LOCATION 1.3 ­ Mojiva 5 required: 1.INTERNET 2.ACCESS_NETWORK_STATE 3.READ_PHONE_STATE optional: 1.ACCESS_FINE_LOCATION 2.READ_CALENDAR 3.WRITE_CALENDAR 4.CALL_PHONE 5.SEND_SMS 6.CAMERA 7.WRITE_EXTERNAL_STORAGE 8.WAKE_LOCK 3.0.2 ­ AdIQuity 9 mandatory: 1.INTERNET optional: 1.ACCESS_NETWORK_STATE 2.READ_PHONE_STATE 2.6 ­ 3.ACCESS_COARSE_LOCATION 4.ACCESS_FINE_LOCATION Cauly 4 mandatory: 1.CALL_PHONE 2.INTERNET 3.ACCESS_FINE_LOCATION 4.ACCESS_NETWORK_STATE 5.WRITE_EXTERNAL_STORAGE 6.READ_EXTERNAL_STORAGE 1.4.8 ­ Vserve 8 mandatory: 1.INTERNET 2.ACCESS_COARSE_LOCATION 3.ACCESS_COARSE_LOCATION 4.ACCESS_NETWORK_STATE 1.2 <activity android:name="mobi.vserv.and
roid.appwrapper.VservAdManag
er" android:theme="@style/Theme
.Sherlock" android:configChanges="orient
ation" /> AdClient 4 mandatory: 1.INTERNET 2.ACCESS_NETWORK_STATE optional: 1.WRITE_EXTERNAL_STORAGE 2.READ_PHONE_STATE 3.ACCESS_FINE_LOCATION 4.ACCESS_COARSE_LOCATION ­ <service android:name="com.adclient.a
ndroid.sdk.synchronization.AdCl
ientSynchronizer"/> <receiver android:name="com.adclient.a
ndroid.sdk.install.DownloadCo
mpleteReceiver"><intent­filter
><action android:name="android.intent.
action.DOWNLOAD_COMPLETE
"/></intent­filter></receiver> MassiveIm
pact 7 1.INTERNET 2.ACCESS_NETWORK_STATE 3.6 <activity android:name="com.massiveim
pact.ad.AdView" /> MobFox 8 mandatory: 1.INTERNET 2.ACCESS_NETWORK_STATE optional: 1.READ_PHONE_STATE 2.ACCESS_FINE_LOCATION 4.1.6 <activity android:name="com.adsdk.sdk.
banner.InAppWebView" android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize"/> <activity android:name="com.adsdk.sdk.
video.RichMediaActivity" android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize" android:hardwareAccelerated="
false"/> <activity android:name="com.adsdk.sdk.
mraid.MraidActivity" android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize"/> activity holding banner should have android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize" declared. Airpush 9 mandatory: 1.INTERNET 2.ACCESS_NETWORK_STATE 3.READ_PHONE_STATE 4.WRITE_EXTERNAL_STORAGE optional: 1.ACCESS_COARSE_LOCATION 2.ACCESS_FINE_LOCATION 3.ACCESS_WIFI_STATE Standard SDK 1.0 Beta <meta­data android:name="com.google.an
droid.gms.version" android:value="@integer/googl
e_play_services_version" /> <activity android:name="<sdk package name>.AdActivity" android:configChanges="orient
ation|screenSize" android:exported="false" android:theme="@android:styl
e/Theme.Translucent" /> <activity android:name="<sdk package name>.BrowserActivity" android:configChanges="orient
ation|screenSize" /> Vdopia 8 1.INTERNET 2.ACCESS_NETWORK_STATE 3.GET_ACCOUNTS 4.READ_PHONE_STATE 5.ACCESS_WIFI_STATE LightWeigh
t SDK for Android <activity android:name="com.vdopia.ad
s.lw.LVDOAdActivity" android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize" /> <activity android:name="com.vdopia.ad
s.lw.mraid.LVDOBrowserActivity
" android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize" /> Vungle 9 1.INTERNET 2.WRITE_EXTERNAL_STORAGE 3.ACCESS_NETWORK_STATE 3.2.2 <meta­data android:name="com.google.an
droid.gms.version" android:value="@integer/googl
e_play_services_version"/> <activity android:name="com.vungle.pu
blisher.FullScreenAdActivity" android:configChanges="keybo
ardHidden|orientation|screenSi
ze" android:theme="@android:styl
e/Theme.NoTitleBar.Fullscreen"
/> <service android:name="com.vungle.pu
blisher.VungleService" android:exported="false"/> Amazon 4 1.INTERNET 2.ACCESS_COARSE_LOCATION 3.ACCESS_FINE_LOCATION 4.ACCESS_NETWORK_STATE 5.ACCESS_WIFI_STATE <activity Amazon Mobile Ads android:name="com.amazon.d
API 5.4.227 evice.ads.AdActivity" android:configChanges="keybo
ardHidden|orientation|screenSi
ze"/> VideMob 10 mandatory: added automatically optional: 1.ACCESS_NETWORK_STATE 2.ACCESS_WIFI_STATE 3.ACCESS_COARSE_LOCATION 4.ACCESS_FINE_LOCATION 2.8.8 <meta­data android:name="com.google.an
droid.gms.version" android:value="@integer/googl
e_play_services_version"/> <provider android:name="com.cydersoft.
core.database.CydersoftConten
tProvider" android:authorities="<your app package name>" android:exported="false" /> BrightRoll 8 1.INTERNET 2.ACCESS_FINE_LOCATION 3.ACCESS_NETWORK_STATE 20140717 <activity android:name="com.brightroll.
androidsdk.AdActivity" android:configChanges="orient
ation|keyboardHidden|uiMode|
screenSize" android:theme="@android:styl
e/Theme.NoTitleBar"/> <meta­data android:name="com.google.an
droid.gms.version" android:value="@integer/googl
e_play_services_version" /> AerServ 10 mandatory: 2.25rc1 <meta­data android:name="com.google.an
droid.gms.version" android:value="@integer/googl
e_play_services_version"/> <activity android:name="com.google.an
droid.gms.ads.AdActivity" android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize"/> <activity android:name="com.aerserv.sd
k.view.ASVastInterstitialActivity
" android:theme="@android:styl
e/Theme.Translucent" 1.INTERNET 2.ACCESS_COARSE_LOCATION 3.ACCESS_FINE_LOCATION 4.ACCESS_NETWORK_STATE 5.READ_PHONE_STATE 6.com.google.android.providers.gs
f.permission.READ_GSERVICES optional: 1.WRITE_EXTERNAL_STORAGE 2.VIBRATE android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize"/> <activity android:name="com.aerserv.sd
k.view.ASWebviewInterstitialAc
tivity" android:configChanges="keybo
ard|keyboardHidden|orientatio
n|screenLayout|uiMode|screen
Size|smallestScreenSize"/> MoPub 9 mandatory: 1.INTERNET 2.ACCESS_NETWORK_STATE optional: 1.ACCESS_COARSE_LOCATION 2.ACCESS_FINE_LOCATION 3.WRITE_EXTERNAL_STORAGE 3.5.0 <activity android:name="com.mopub.m
obileads.MoPubActivity" android:configChanges="keybo
ardHidden|orientation|screenSi
ze"/> <activity android:name="com.mopub.m
obileads.MraidActivity" android:configChanges="keybo
ardHidden|orientation|screenSi
ze"/> <activity android:name="com.mopub.co
mmon.MoPubBrowser" android:configChanges="keybo
ardHidden|orientation|screenSi
ze"/> <activity android:name="com.mopub.m
obileads.MraidVideoPlayerActivi
ty" android:configChanges="keybo
ardHidden|orientation|screenSi
ze"/> <meta­data android:name="com.google.an
droid.gms.version" android:value="@integer/googl
e_play_services_version"/> />* Here are some examples: <uses­permission android:name="android.permission.INTERNET" /> <uses­permission android:name="android.permission.READ_PHONE_STATE" INTERNET Allows application to use network connection sockets. Make sure the INTERNET permission is enabled to allow the SDK to access the network and exchange ads with ad servers. READ_PHONE_STATE* Allows application to access the phone state in read only mode.​
This permission is enabled for getting the device ID, which allows app to benefit from highly targeted campaigns. * ​
In case of using AdMob, InMobi, YOC Performance or Mojiva as ad providers this permission is not required​
. You can enable location targeting in your app, ​
which means configuring your app to receive location­based ads. Enable the optional ​
ACCESS_COARSE_LOCATION ​
and ACCESS_FINE_LOCATION ​
permissions to allow the SDK to access the user location details. ACCESS_COARSE_LOCATION Allows an application to access coarse (Cell­ID, Wi­Fi) location. ACCESS_FINE_LOCATION Allows an application to access fine (GPS) location. ACCESS_NETWORK_STATE permission allows to detect network connectivity and in this way enable ad rotation in your app. ACCESS_NETWORK_STATE Allows an application to view the state of all networks. WRITE_EXTERNAL_STORAGE Allows an application to write to external storage. READ_EXTERNAL_STORAGE Allows an application to read to external storage. CALL_PHONE Allows application to perform phone calls. /> With all the above your final AndroidManifest.xml may look something like this: <uses­permission android:name="android.permission.INTERNET" /> <uses­permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses­permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses­permission android:name="android.permission.READ_PHONE_STATE" /> <uses­permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses­permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" Also, you need to specify synchronization service, download receiver and popup activity in your application’s manifest file, somewhere between <application> and </application> tags: <service android:name="com.adclient.android.sdk.synchronization.AdClientSynchronizer" /> <receiver android:name="com.adclient.android.sdk.install.DownloadCompleteReceiver"> <intent­filter> <action android:name="android.intent.action.DOWNLOAD_COMPLETE" /> </intent­filter> </receiver> <activity android:name="com.adclient.android.sdk.install.AdClientPopupActivity" android:theme="@android:style/Theme.Dialog"/> The below lines need to be added, too, because they are required by AdMob and InMobi mobile advertising networks: <activity android:name="com.inmobi.androidsdk.IMBrowserActivity" android:configChanges="keyboardHidden|orientation|keyboard" /> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screen
Layout|uiMode|screenSize|smallestScreenSize"/> In case of using Millenial Media ads following needs to be added: <activity android:name="com.millennialmedia.android.MMActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation|keyboard" > </activity> <activity android:name="com.millennialmedia.android.VideoPlayer" android:configChanges="keyboardHidden|orientation|keyboard" > </activity> When using Inneractive as ad source add following to Your AndroidManifest.xml file: <activity ​
android:name​
="com.inneractive.api.ads.InneractiveFullScreenView" /> When using TapIt as ad provider add following into AndroidManifest.xml before </application>: <activity android:name="com.tapit.adview.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation"/> In case of using Cauly as ad provider clicks may not be accounted by system. Given all the above, your sample application’s Manifest.xml file is likely to look like this: <?xml version="1.0" encoding="utf­8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.adclient.test" android:versionCode="3" android:versionName="4.5.0"> <application android:label="@string/app_name" android:debuggable="true"> <activity android:name=".TestAdClientSDK" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation|keyboard"> <intent­filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent­filter> </activity> <activity android:name="com.inmobi.androidsdk.IMBrowserActivity" android:configChanges="keyboardHidden|orientation|keyboard" /> <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout |uiMode|screenSize|smallestScreenSize"/> <service android:name="com.adclient.android.sdk.synchronization.AdClientSynchronizer" /> </application> <uses­sdk android:minSdkVersion="3"/> <uses­permission android:name="android.permission.INTERNET"/> <uses­permission android:name="android.permission.READ_PHONE_STATE"/> <uses­permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses­permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses­permission android:name="android.permission.ACCESS_NETWORK_STATE"/> </manifest> 3. Obtaining your key In order to ensure the best experience ​
you should disable refresh in any external ad providers that you may use. Make sure you have your key on hand for the rest of the implementation, taken from our website or provided by your personal account manager. Key is essential entity that identifies you within the system. It is the only mandate prerequisite for getting started as AdClientSDK user. 4. Integration To make the integration process more flexible and as easy as possible, we are offering two ways of adding the AdClientView to your application: 1. As a tag in the layout XML file. 2. As API for ​
forming and displaying ad viewing element from your code at runtime. Way #1: Declarative description in layout file. In order to add AdClientView to your layout : ​
a​
. Add attributes set in the XML layout for this view into res/values (attrs.xml). Paste the following configuration parameters into your attrs.xml file: <resources> <declare­styleable name="com.adclient.app.configuration"> <attr name="key" format="string"/> <attr name="refreshInterval" format="integer"/> <attr name="adType" format="string"/> <attr name="viewBackground" format="string"/> ​
<attr name="custom" format="string" /> <attr name="adServerUrl" format="string" /> </declare­styleable> </resources> Here are the ​
mandatory ​
parameters you ​
MUST​
add to your layout file: key thekey provided during the registration process adServerUrl Target URL for ads requests. Here are the ​
optional​
parameters you can add to your requests: refreshInterval Time frequency of ads refreshing, in seconds. The minimum refresh interval is 15 seconds, and the maximum is 90 seconds, which is 1.5 minutes. In case this parameter is omitted or entered value is out of specified bounds, value of 15 seconds is being applied. IN ORDER TO ENSURE BEST USER EXPERIENCE WE COMPEL YOU TO DISABLE ALL EXTERNAL REFRESH MECHANISMS. Not being used while requesting interstitial ad. adType​
* The type of the ad you want to display. Currently supported values are: ​
BANNER_320X50 BANNER_300X250 BANNER_468X60 BANNER_728X90 BANNER_120X600 INTERSTITIAL Background color of ad displaying view given as word describing specified color. app:viewBackground = “magenta” Defaults to black when not specified explicitly. custom Additional parameters string. viewBackground * ​
In case if some outer ad network doesn’t support some format, it rollbacks to default ​
banner_320X50. b. ​
Insert a reference into the ​
attrs.xml​
file in your layout element : Insert a reference to the ​
attrs.xml file in your layout element by adding xmlns line that includes your package name specified in ​
AndroidManifest.xml​
. For example, if your package name is com.adclient.sample, you would include this line: xmlns:app = "http://schemas.android.com/apk/res/com.adclient.sample" . c. ​
Add AdClientView to the layout: <com.adclient.android.sdk.view.AdClientView android:id="@+id/adClientView" android:layout_width="fill_parent" android:layout_height="wrap_content" app:key="49d835910115c8523f80db8405b77ae9" app:refreshInterval="20" app:adType="banner_ad" app:custom=”option=my_option” app:adServerUrl =”​
http://my.ads.host:8080/​
” /> Your sample application may look something like 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:padding="4dip" android:textSize="16sp" /> <com.adclient.android.sdk.view.AdClientView android:id="@+id/adClientView" android:layout_width="fill_parent" android:layout_height="wrap_content" app:key="49d835910115c8523f80db8405b77ae9" app:refreshInterval="20" app:adType="banner_ad" app:custom=”option=my_option” /> <Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> </LinearLayout> Way #2: Imperative creating at runtime. In order to create AdClientView element programmatically: a. ​
Prepare configuration parameters map: Map<ParamType , String> params = new HashMap<ParamType , String>();
params.put(ParamsType.KEY,”49d835910115c8523f80db8405b77”);
params.put(ParamsType.REFRESH_INTERVAL,”25”); Map<String, Object> customParams = new HashMap<String, Object>(); customParams.put("make", "1234"); configuration.put(ParamsType.CUSTOM, customParams); Here are all the parameters that you can use: ParamsType​
.KEY ​
­ User key. ParamsType​
.REFRESH_INTERVAL ​
­ time for ad refresh. ParamsType​
.ADTYPE ​
­ specific ad type. ParamsType.​
CUSTOM ​
­ map of additional parameters(key,value pairs). ParamsType.​
AD_SERVER_URL ​
­ target URL for ad requests. b. ​
Create AdClientView object using one of the following constructors: public AdClientView(Context context);
public AdClientView(Context context, AttributeSet attrs);
public AdClientView(Context context, AttributeSet attrs, int defStyle); c. ​
Assign created parameters map to AdClientView object: adClientView.setConfiguration(params); d. ​
Place created adClientView somewhere within your existing layout: LinearLayout myLayout = (LinearLayout) findViewById(R.id.main);
myLayout.addView(adClientView); AdClientView element starts requesting for ads right after creation. In order to properly manage AdClientView lifecycle call it methods ​
resume()​
, ​
pause()​
, and ​
destroy() in the corresponding Activity methods: @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. Interstitial ads In case of declaring AdClientInterstitial view as part of the layout markup interstitial going to be shown once when layout being inflated: <com.adclient.android.sdk.view.AdClientInterstitial android:layout_width="fill_parent" android:layout_height="wrap_content" app:key="8ded375f9ac9fe65e8ccd84a99b5439c" app:adType="INTERSTITIAL" /> AdClientInterstitial class can also be used programmatically to trigger interstitials showing in any place of you app: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main); final Context context = this; final View layout = findViewById(R.id.mainLayout);
final AdClientInterstitial interstitial = new AdClientInterstitial(context); HashMap<ParamsType, Object> configuration = new HashMap<ParamsType, Object>(); configuration.put(ParamsType.KEY, "8ded375f9ac9fe65e8ccd84a99b5439c"); configuration.put(ParamsType.ADTYPE, AdType.INTERSTITIAL.toString()); interstitial.setConfiguration(configuration);
interstitial.setServerAdListener(new ServerAdListener() { public void onReceivedAd(AbstractAdClientView adClientView) { Log.d("TestApp", "­­> Ad received callback."); } public void onFailedToReceiveAd(AbstractAdClientView adClientView) { Log.d("TestApp", "­­> Ad failed to be received callback."); } public void onShowAdScreen(AbstractAdClientView adClientView) { Log.d("TestApp", "­­> Ad show ad screen callback."); } }); ((ViewGroup)layout).addView(interstitial); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { interstitial.show();
} }); } In order to properly manage AdClientInterstitial lifecycle call it methods ​
resume()​
, pause()​
, and ​
destroy()​
in the corresponding Activity methods: @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(); } 6. Debugging MRAID ads AdClient Android SDK gives You an option to debug custom MRAID­powered ads. You can use ​
mraid.logEntry(message) ​
at any place in Your richmedia banner to pass some piece of information to Android logging facility. 7. Location Updates AdClient SDK for Android allows the API to control location updates retrieval from users’ devices. Use the LocationWatcher interface to access location update management methods: boolean watch() ­ ensures that coordinates of the user’s device are sent with every ad request; boolean unWatch() ­ removes location listener, no coordinates will be requested or sent with the ad request; final AdClientView banner = (AdClientView) findViewById(R.id.bannerView); banner.getLocationWatcher().unWatch(); These methods are called automatically when the visibility of the application window changes, so you cannot use them to permanently stop location updates. Instead, to permanently change location update methods and intervals use: Map<String, LocationWatcher.LocationProviderInfo> locationProviderMap = banner.getLocationWatcher().getLocationProviderMap(); 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 call: locationProviderMap.get(LocationManager.NETWORK_PROVIDER).setMinTime(5000); locationProviderMap.get(LocationManager.GPS_PROVIDER).setMinTime(600000);
and to completely disable location updates call locationProviderMap.clear() for each banner. 8. Test Mode Some (but not all) vendor SDKs allow specifying test mode for serving ads. To make Adclient SDK enable the test mode for some of the supported SDKs call AdClientView.setTestMode(true); Please note that test mode may be applied only partially so some ads will continue to be served in production mode.