Adding advertising to your apps is easy. Integrating ads doesn’t require a major redesign of your app and has minimal impact on your app’s functionality. It is as simple as making space for the ad on the screen. The Amazon Mobile Ads API (Beta) enables you to display high-quality ads provided from the Amazon Mobile Ad Network in a matter of minutes. This article explains how to place ads into an existing app using the Amazon Mobile Ads API.
First and foremost, submit your payment information through the Payment Information Page and your tax information through the Tax Identity Interview. You can skip this step if you have already submitted this information through the Amazon Mobile App Distribution Portal. This is required to receive ads.
The Amazon Mobile Ads API utilizes a unique Application Key to identify and interact with an app. Every app will have its own Application Key. If your app is already on the Distribution Portal, you can find your Application Key on the app’s detail page. Otherwise, create a new app and fill in the “App title” and “Category” fields. Locate the Application Key value and set that aside. We will use that later to register with the Amazon Mobile Ad Network.
Next, you will need to add the Amazon Mobile Ads API to your project. For the purposes of this example, we will use Eclipse.
Download the Amazon Mobile Ads API (Beta) from here (this should link to our API landing page which has the file for download and the legal verbiage) and unzip it locally.
Add the JAR to Your Project
Modify the build path of your project and add the amazon-ads-<x.y.z>.jar found in the zip under the /Ads/lib folder.
This step is required to set up ads through the xml layout. Copy the amazon_ads_attr.xml file from the zip located in /Ads/res/values/ into your project’s res/values/ folder.
The Amazon Mobile Apps API requires the following permissions and activities:
<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.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<activity android:name="com.amazon.device.ads.MraidBrowser" android:configChanges="keyboardHidden|orientation"/>
<activity android:name="com.amazon.device.ads.VideoActionHandler" android:configChanges="keyboardHidden|orientation|screenSize"/>
Now that the project is set up to use the Amazon Mobile Ads API, the next step is to add an ad to the application layout.
Now we can call the Amazon Mobile Ads API to load ads.
Time to put that Application Key to work. In your activities onCreate, call the AdRegistration method to register your app and then call the Amazon Mobile Ads API to load an ad. Please note that you may only use an Application Key to display ads on the specific app for which it was issued.
//Register App with the Ad Network
//Load ad on to AdLayout
adview = (AdLayout)findViewById(R.id.adview);
Submit your app to Amazon to display ads to your U.S. users and follow the attribution guidelines set forth here. The Amazon Mobile Ads API can also be used with apps that are distributed through any Android stores. Apps that use the Amazon Mobile Ads API may be distributed through any Android store as long as they are distributed through Amazon.
Your app is ready to display high-quality ads from the Amazon Mobile Ad Network. This is the simplest of configurations but the Amazon Mobile Ads API has several features for customizing your ad layout, ad targeting, error handling, debugging, and more. Read more about the many features of the Amazon Mobile Ads API (Beta) here.