Mobile Ads 101: Part I

Monetizing Android Apps with ONE by AOL: Mobile

Malcom Jones
6 min readJun 7, 2017

In today’s app economy there are various monetization models, such as freemium, subscription, and advertising. This article focuses on the latter and serves as a beginners guide to integrating the ONE by AOL: Mobile ad platform into your app. This guide will cover:

  • Creating a ONE by AOL: Mobile account
  • Integrating the SDK
  • Common Pitfalls

Part I of this guide will focus on Android, with followup guides for iOS, ad network mediation, and more. This is not meant to cover every detail of the SDK, but to give you a good start in monetizing your apps and mobile websites. A deeper dive into the SDK can be found at the references provided by AOL down at the bottom of this guide.

Part II: Monetizing iOS Apps with ONE by AOL: Mobile

All of the code referenced in this guide can be found on my GitHub.

Disclaimer: Though I work for AOL, this blog is of my own volition and is not an endorsement by AOL of any non-AOL entities that may be cited

ONE by AOL: Mobile Account Setup

Before we dive into SDK integration, we will briefly look at how to sign up for an account with ONE Mobile and discuss terms specific to the platform. You can start by going to onemobile.aol.com and clicking the Create One link. After signing up, you should receive an email within 48 hours with a link to activate your account. Upon signing in for the first time, you will be presented with an empty dashboard that will show data about your apps once you have integrated the platform.

Distinct to the ONE Mobile platform are identifiers used for your app and ad slots: SiteIDs and Placements. SiteIDs are unique hexadecimal numbers that are used to represent your mobile site or app on the platform. In addition to SiteIDs, each site has unique Placements which are ad slots for the various ad types: banner, interstitial, or medium rectangle. When integrating the SDK later in this guide, you will need to know your SiteID and respective Placements to serve ads, but do not need them to begin integration of the SDK.

When logged in to your ONE Mobile account, you can create a new site by selecting the Applications and Sites tab. Completing the information in this tab will generate a SiteID for you and allow you to create Placements for your app.

Now that the back office piece is taken care of, we can move on to the tech tidbits!

SDK Integration

For this guide, I will be using a sample application that will be made available on GitHub. It gives a general overview of how ads are integrated, but the details may differ from app to app. Feel free to clone or download this repo and tinker with the app yourself.

Download and Add the SDK to Your Project

To begin, head over to the ONE Mobile developer site to download the mobile ad SDK. This site also contains setup documentation, mediation notes, and other useful tidbits. Once downloaded, place the SDK in an easy to find location as you will need to integrate it into your project.

Open your project in Android Studio and change the project files view structure to Android. From there, right-click on the app folder and select Open Module Settings.

Within the Project Structure dialog box, select the + sign in the upper left corner, select Import .JAR/.AAR Package, and then find the ONE Mobile SDK you downloaded earlier. Close the module settings window and allow Gradle to rebuild.

Go back into your module settings and you should now see android-ad-sdk listed under Modules in the left hand column. Select app within that column and select the Dependencies tab. From there, select the + sign, then Module dependency from the dropdown, and select the newly added SDK module. The module should now appear in your dependency list.

Configure Android Manifest

The AndroidManifest.xml file provides essential information necessary to the proper running of your app. We will add a few permissions and a provider in order to ensure ads are successfully displayed within your app.

After the opening <manifest> element, you should place permissions for access to network and WiFi states, internet, location, storage, calendar, NFC, bluetooth, vibration, and audio recording. These permissions are required for full support of the Interactive Advertising Bureaus MRAID v2.0.

Along with these permissions, a MediaContentProvider is required before the closing </application> element.

Create Application Subclass and Initialize SDK

After configuring your manifest, you can now create a subclass of your app where the SDK will be initialized. To do this in Android Studio, create a new Java class (or Activity) that extends Application. In the onCreate() method, we will initialize the SDK and set our SiteID.

Inline Ads

Now that the basic SDK integration is complete, we will look at serving an inline ad. Inline ads take form as either banner (320x50) or medium rectangles (320x250) in mobile apps and appear inline with other app content. For this guide we will assume the banner is to be displayed in its own BannerActivity, something that will most likely differ in your app. You can use a button to navigate from the MainActivity to the BannerActivity, but we won’t delve into that in this guide.

To do this, we must edit both the BannerActivity class and layout. The layout will need to contain a container for the ad content, set at the appropriate size, for the ad you would like to serve. In this example, we will use a simple RelativeLayout containing a LinearLayout for the banner ad.

Within the onCreate() method of the BannerActivity we need to create a View for the banner ad, create an instance of InlineAd, and finally request the ad to be served. The code for this is shown below:

With that, you have integrated your first banner ad. Next up are interstitials!

Interstitial Ads

Interstitials are fullscreen ads that display over the content of your app. They typically occur during game breaks or before other types of content are shown to the user. As mentioned earlier in this guide we will assume the interstitial is to be displayed in its own InterstitialActivity, something that will most likely differ in your app.

Like banners, we will need to edit both the class and layout files. Unlike banners, because Interstitials hover above content, we will not need a container to hold the ad. Instead we will create buttons to load and show the ad. In most applications, Interstitials are pre-loaded in the background to enhance the user experience and these buttons will mimic that behavior. In this example, we will use a simple RelativeLayout containing two buttons.

Within the onCreate() method of the InterstitialActivity we need to create an instance of InterstitialAd, load it, and finally show the ad. These latter two are done with the loadAd() and showAd() methods respectively. The code for this is shown below:

With that, you are able to serve Interstitial ads and you’ll be making money in no time!

Common Pitfalls

  • Missing Google Play Services — Remember to add this module like you did for the SDK
  • SDK must be initialized in the subclass onCreate() method
  • Add the subclass to the Android Manifest name attribute inside the <application> element
  • Remember to add the MediaContentProvider to the manifest

References

--

--