FeedAd Android SDK

This guide explains how to integrate the FeedAd SDK into an Android app.

Requirements

  • Android API from Android 4.3. upwards (API 18+)
  • Gradle 4.1+
  • Gradle Android Plugin 3+
  • A FeedAd client token to be found in the admin panel

Installation

The SDK dependency can be included via the following entry inside the app's build.gradle:

repositories {
    mavenCentral()
}

dependencies {
    implementation('com.feedad.android:feedad-sdk:1.1.12') {
        transitive = true
    }
}

You also have to include the android support library if your app does not already depend on it. If you depend on a newer version than 27.1.1, you do not have to downgrade your dependency.

dependencies {
    // add this line if you don't already include it
    implementation 'com.android.support:appcompat-v7:27.1.1'
}

Sync your gradle files and build your project after adding the dependencies.
Your IDE should now be able to find the class com.feedad.android.FeedAd.

Initialization

The SDK needs to be initialized at application level.
Call the FeedAd.init(...) method inside the onCreate() method of your application:

public class MyApp extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        boolean loggingEnabled = true; // if the SDK should log debug messages to logcat
        FeedAd.init(this, "your client token", loggingEnabled);
    }
}

Integration

Add a FeedAdView to your layout to quickly check if everything is working as expected:

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <!-- your other views -->

    <com.feedad.android.FeedAdView
        android:id="@+id/texture_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:feedadPlacementId="your-placement-id"
        />

    <!-- your other views -->

</LinearLayout>

Placement ID?

You can choose placement IDs yourself. A placement ID should be named after the ad position inside your product. For example, if you want to display an ad inside a list of news articles, you could name it "ad-news-overview".
A placement ID may consist of lowercase a-z, 0-9, - and _. You do not have to manually create the placement IDs before using them. Just specify them within the code, and they will appear in the FeedAd admin panel after the first request. Learn more about Placement IDs and how they are grouped to play the same Creative

It's a wrap!

If you start your app, you should now be able to see ads running wherever you've included the view.
If there are no ads yet, you should enable test ads through the FeedAd admin panel.

It's time to learn more:

  1. See multiple ways to integrate FeedAds into your app
  2. Learn about configuration options and how to manage the SDK's playback
  3. Listen to the SDK's events
  4. Learn how to add interstitial Ads into your app

Demo Apps

If you rather prefer to dive right into the code, you can also take a look at our Android demo apps written in Java that demonstrate a working integration.