Initializing the SDK

Adspostx partners can use the Android SDK to display overlay or embedded placements. The Android SDK is deployed using Maven and Gradle.

All use cases of the SDK follow the same initial steps to integrate and initialize the SDK. At a high level, these steps are:

  1. Add the Adspostx Android SDK module

  2. Initialize the Adspostx Android SDK

Following these steps, the execute method of the SDK can then be used in various ways to suit the required use case.

Before you begin

This guide assumes that you are familiar with Gradle and know how to install a plugin for Android development.

Setting up the Android SDK

  1. Add the Jitpack plugin repository URL in the build.gradle file for the project.

// file => build.gradle (Project: ....)

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

2. Add the Adspostx Android SDK module to build.gradle for the module.

// file => build.gradle (Module: ...)

dependencies {
    ...
    // Note: 1.0.0 reflects the latest version of the Adspostx Android SDK.
    implementation 'com.github.donkeydevelopers:adspostx:1.0.0'
    ...
}

3. Initialize the Adspostx SDK prior to using it in any activity.

import com.adspostx.AdpostxDialogFragment

public class LauncherActivity extends Activity, AdpostxDialogDismissListener {
    override fun onCreate(savedInstanceState: Bundle?) {
        ...
        // The following will reveal a demo integration. To view your integration:
        var adpostxDialogFragment = AdpostxDialogFragment.newInstance(DialogParams(),this)
        
        // To show the dialog 
        adpostxDialogFragment.show(supportFragmentManager, AdpostxDialogFragment::class.java.canonicalName)
        ...

        // Optional : To dismiss the dialog (close button is already implemented inside the dialog
        adpostxDialogFragment.dismiss()
        ...

    }
    
    // Adspostx Dialog DismissListener
    override fun dismissListener() {
        Toast.makeText(this, "Dialog Dismissed", Toast.LENGTH_SHORT).show()
    }
}

Last updated