This page will show you how to integrate Leadbolt Native ads using our integration-friendly Native templates in your Android app.

To get started sign up for a Leadbolt Publisher account here or login to the Publisher Portal here.

gstart


Before you begin Before you begin

  • Have you signed up and logged in to the Leadbolt Publisher Portal?
  • Did you add an App in the portal?
  • Ensure, you have downloaded the Leadbolt SDK and sample app from the link above
  • Add the required permission android.permission.INTERNET in your AndroidManifest.xml file
  • Add the required permission android.permission.ACCESS_NETWORK_STATE in your AndroidManifest.xml file
  • To ensure your App is compatible with Android 6.0 and above devices, set the project’s Build and Compile SDK Version to API Level 25 or above in your build.gradle file

    compileSdkVersion = 25
    buildToolsVersion = '25.0.3'
  • Also set the Target SDK Version in your App’s AndroidManifest.xml file to 23 or higher to target Android 6.0 features
    android:targetSDKVersion="25"

     


Step 1 Add Leadbolt SDK Jar file

  • Copy the downloaded AppTracker.jar file to your Android Project’s “libs” folder. If folder doesn’t exist, create one and add the jar file to it

Step 2 Add Google Play Services

  • The Google Play services are needed to be added in your App to enable the Leadbolt SDK to use the Google Advertising ID.
  • Follow the setup instructions from Google to include the library in your App.

Step 3 Add Leadbolt SDK Imports

  • Add the following Leadbolt SDK import statements to all your App’s Activities that will use the Leadbolt SDK.


Step 4 Initialize Leadbolt SDK

  • In your App’s launcher Activity, add the following code to your Activity’s onCreate method.

    You will need to replace "YOUR_APP_API_KEY"  with the specific api key for your app (include the double quotes).


Step 5 To fetch a Native Ad


Step 6 To show a Native Ad

  • Use the onAdsLoaded method in the ATNativeListener class to get notified

Test Integration Test your Integration

  • Run your Project on an Android device.
  • Ensure, test ads are displayed when the “loadModule” call is made in your App.
  • Once test ads are seen on your device, go to your Leadbolt Portal and set your App to “Live”
  • Once approved, you should see live ads in your App.

Congratulations! You have successfully integrated the Leadbolt SDK in your App
 


Troubleshooting


Advanced Integration

Pass Additional Info Passing Additional Information

You can increase your App’s performance by optionally including the additional information below. This allows selected premium advertisers to display their Ads to your users. To pass this additional information, use the following methods BEFORE calling loadModuleToCache


Event Listeners Using Event Listeners

With Event listeners, you can closely follow the ad states throughout your App. Leadbolt SDK will trigger events at all important stages of the Ad life-cycle. To implement event listeners in your App, you must implement the ATNativeListener class.

Setup SDK to use Event Listeners

Before using any of the Event Listener methods, you will need to initialize your Event Listener object in your Project like so:

Now, set AppModuleListener in your onCreate method BEFORE calling AppTracker.startSession() like so:

Event Listener Methods


gstart

← Return to Help Center