Documentation Version 0.5 ADITION Android Ad SDK Integration Guide for App Developers SDK Version 1 as of 2013 01 04 Copyright 2012 ADITION technologies AG. All rights reserved. 1/7
Table of Contents 1. Ad SDK Requirements 1.1 Requirements for Orientation Changes 2. Integrating the SDK in a Project 3. Displaying an Ad 3.1 Displaying an Inline Ad 3.1.1 Integration in XML 3.1.2 Programmatic Integration 3.1.3 Resize Ads in ScrollViews 3.2 Displaying an Interstitial 3.3 Defining a custom browser 3.4 Setting the viewable state of an ad 4. Demo Project Copyright 2012 ADITION technologies AG. All rights reserved. 2/7
1. Ad SDK Requirements Apps that make use of the SDK must be built for Android version 2.1 or later. In your Manifest you have to define the following permissions: <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> You also have to define the following Activity in your Manifest: <activity android:name="com.adition.android.sdk.aditionactivity"></activity> 1.1 Requirements for Orientation Changes To prevent the Ad from reloading while changing the devices orientation, the App Developer should handle orientation changes himself. To do so, the activities that show Ads, should be defined with the following parameters in the Manifest: android:configchanges="orientation keyboardhidden screensize" 2. Integrating the SDK in a Project In order to use the Adition SDK the App Developer has to copy the adition.jar file into the projects libs folder and add the library to its buildpath. If the libs folder does not exist, it needs to be created in the root of the project. 3. Displaying an Ad There are two options for displaying ads: inline: integrated in your layout interstitial: on top of the content (decoupled from layout) 3.1 Displaying an Inline Ad Copyright 2012 ADITION technologies AG. All rights reserved. 3/7
For displaying an Inline Ad you have to add an AditionView to your layout. This can be done in XML or programmatically in code. 3.1.1 Integration in XML <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.adition.android.sdk" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <com.adition.android.sdk.aditionview android:layout_width="wrap_content" android:layout_height="wrap_content" ads:content_unit_id="your_content_unit_id" ads:network_id="your_network_id" ads:max_width="400dp" ads:max_height="100dp" ads:keyword="your_kewords" ads:human_language="your_language" ads:tracking_group_name="your_tracking_group_name" > </com.adition.android.sdk.aditionview> </LinearLayout> 3.1.2 Programmatic Integration String networkid = "YOUR_NETWORK_ID"; String contentunitid = "YOUR_CONTENT_UNIT_ID"; Context context = YOUR_CONTEXT e.g. your Activity; boolean isinline = true; // your container layout LinearLayout l = (LinearLayout) findviewbyid(r.id.container); // programmatically creating AditionView AditionView aditionview = new AditionView(context, contentunitid, networkid, isinline); // optional parameters aditionview.setkeyword(keyword); aditionview.sethumanlanguage(your_language); aditionview.settrackinggroupname(tracking_group_name); Copyright 2012 ADITION technologies AG. All rights reserved. 4/7
// add the AditionView to layout l.addview(aditionview, LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); // start loading content of ad aditionview.execute(); 3.1.3 Resize Ads in ScrollViews Resize Ads are non-modal overlays, so the user can still interact with the content of the App. To make them work in ScrollViews the App Developer has to use the provided AditionScollView which moves the AditionView according to the scroll movements. Layout XML: <com.adition.android.sdk.aditionscrollview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.adition.android.sdk" android:id="@+id/asv" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <!-- CONTENT GOES HERE e.g. <com.adition.android.sdk.aditionview> </com.adition.android.sdk.aditionview> --> </LinearLayout> </com.adition.android.sdk.aditionscrollview> Registering AditionView programmatically to AditionScrollView to track scroll movements. AditionScrollView asv = (AditionScrollView) findviewbyid(r.id.asv); asv.setaditionview(aditionview); 3.2 Displaying an Interstitial Copyright 2012 ADITION technologies AG. All rights reserved. 5/7
Interstitial Ads are displayed on top of the content. They are decoupled from the layout. So it is not possible to define them via XML; the app developer has to create them programmatically. String networkid = "YOUR_NETWORK_ID"; String contentunitid = "YOUR_CONTENT_UNIT_ID"; Context context = YOUR_CONTEXT e.g. your Activity; boolean isinline = false; // programmatically creating AditionView AditionView aditionview = new AditionView(context, contentunitid, networkid,, isinline); // optional parameters aditionview.setkeyword(keyword); aditionview.sethumanlanguage(your_language); aditionview.settrackinggroupname(tracking_group_name); // start loading content of ad aditionview.execute(); // show the interstitial aditionview.showinterstitial(); 3.3 Defining a custom browser The Adition SDK gives the App Developer the option to integrate a custom browser, which opens the clicked ads, e.g. for branding purposes. Custom browsers must implement the AditionBrowser interface and override openbrowserforad(string url) which decides what to do with the given url. By calling setbrowser(aditionbrowser browser)on the AditionView the custom browser is set. CustomBrowser cb = new CustomBrowser(aContext); aditionview.setbrowser(browser); 3.4 Setting the viewable state of an ad To notify the ad creative about the current visibility of the ad container the app developer has to call setviewable(boolean isviewable) on the AditionView instance when the visibility of the container changes (e.g. other content is on top of the ad container). Copyright 2012 ADITION technologies AG. All rights reserved. 6/7
4. Demo Project For demonstrating the minimum effort needed to display an ad, we have added a demo project. You can either copy the adition.apk directly to your Android Device or import the contents of the adition folder into an Eclipse workspace and run it from there on an emulator or a real device. The projects AdActivity class contains the relevant demo code to show the ads. Copyright 2012 ADITION technologies AG. All rights reserved. 7/7