Skip to main content

Adrop

The main class of the Adrop SDK. Handles SDK initialization and global settings.

Static Methods

MethodDescription
initialize(context: Application, production: Boolean)Initializes the SDK.
initialize(context: Application, production: Boolean, targetCountries: Array<String>)Initializes the SDK with target countries.
initialize(context: Application, production: Boolean, targetCountries: Array<String>, tokenKey: String?)Initializes the SDK with target countries and token key.
setUID(uid: String)Sets the user identifier. (Hashed with SHA-256)
setTheme(theme: AdropTheme)Sets the ad theme.
setTokenKey(tokenKey: String)Sets the app token key.
handleDeepLink(intent: Intent): BooleanHandles Adrop deep links.
openQuest(context: Context, channel: String, path: String?)Opens the Adrop Quest page.

Static Properties

PropertyTypeDescription
isProductionBooleanWhether in production mode
sdkVersionStringSDK version

Usage Example

// Initialization
Adrop.initialize(application, production = true)

// Set user ID
Adrop.setUID("user123")

// Set theme
Adrop.setTheme(AdropTheme.DARK)

// Handle deep link
override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    intent?.let { Adrop.handleDeepLink(it) }
}

AdropTheme

Enum for setting dark mode for ads.

Values

ValueDescription
LIGHTLight mode
DARKDark mode
AUTOFollow system settings automatically (default)

Usage Example

Adrop.setTheme(AdropTheme.DARK)

AdropErrorCode

Error codes that may occur when loading and displaying ads.

Values

Error CodeDescription
ERROR_CODE_NETWORKNetwork error
ERROR_CODE_INTERNALInternal error
ERROR_CODE_INITIALIZESDK initialization error
ERROR_CODE_INVALID_UNITInvalid ad unit ID
ERROR_CODE_NOT_TARGET_COUNTRYNot in target country
ERROR_CODE_AD_INACTIVEInactive ad
ERROR_CODE_AD_NO_FILLNo ad available to display
ERROR_CODE_AD_LOAD_DUPLICATEDDuplicate ad load request
ERROR_CODE_AD_LOADINGAd is loading
ERROR_CODE_AD_EMPTYAd is empty
ERROR_CODE_AD_SHOWNAd has already been shown
ERROR_CODE_AD_HIDE_FOR_TODAY”Don’t show today” is set
ERROR_CODE_ACCOUNT_USAGE_LIMIT_EXCEEDEDAccount usage limit exceeded
ERROR_CODE_LANDSCAPE_UNSUPPORTEDLandscape mode not supported

AdropBanner

View class for displaying banner ads.

Constructor

// Use in XML
AdropBanner(context: Context, attrs: AttributeSet?)

// Use in code
AdropBanner(context: Context, unitId: String, contextId: String? = null)

Properties

PropertyTypeDescription
listenerAdropBannerListener?Banner event listener
shouldAdjustHtmlStyleBooleanWhether to auto-adjust HTML style (default: false)
useCustomClickBooleanWhether to use custom click handling (default: false)
adSizeCreativeSize?Banner size for backfill ads (dp)
contextIdStringContext ID
creativeIdStringCreative ID
txIdStringTransaction ID
campaignIdStringCampaign ID
destinationURLStringDestination URL
creativeSizeCreativeSizeCreative size
isBackfilledBooleanWhether it’s a backfill ad

Methods

MethodDescription
setUnitId(unitId: String)Set ad unit ID
getUnitId(): StringGet ad unit ID
load()Load ad
open(url: String?)Open ad landing page
destroy()Destroy banner ad

Usage Example

val banner = AdropBanner(this, "YOUR_UNIT_ID")
banner.listener = object : AdropBannerListener {
    override fun onAdReceived(banner: AdropBanner) {
        // Ad received successfully
    }

    override fun onAdFailedToReceive(banner: AdropBanner, errorCode: AdropErrorCode) {
        // Failed to receive ad
    }

    override fun onAdClicked(banner: AdropBanner) {
        // Ad clicked
    }
}

// Load ad
banner.load()

AdropBannerListener

Interface for handling banner ad events.

Methods

MethodDescription
onAdReceived(banner: AdropBanner)Ad received successfully
onAdClicked(banner: AdropBanner)Ad clicked
onAdImpression(banner: AdropBanner)Ad impression (optional implementation)
onAdFailedToReceive(banner: AdropBanner, errorCode: AdropErrorCode)Failed to receive ad
All callbacks are called on the main thread (@UiThread).

AdropNativeAd

Class for displaying native ads.

Constructor

AdropNativeAd(context: Context, unitId: String, contextId: String? = null)

Properties

PropertyTypeDescription
listenerAdropNativeAdListener?Native ad event listener
useCustomClickBooleanWhether to use custom click handling
contextContextContext
isLoadedBooleanWhether ad loading is complete
isDestroyedBooleanWhether ad is destroyed
creativeIdStringCreative ID
txIdStringTransaction ID
campaignIdStringCampaign ID
creativeSizeCreativeSizeCreative size
iconStringIcon image URL
coverStringCover image URL
headlineStringHeadline
bodyStringBody text
creativeStringCreative URL
assetStringAsset URL
destinationURLStringDestination URL
advertiserURLStringAdvertiser URL
accountTagJSONObjectAccount tag
creativeTagJSONObjectCreative tag
advertiserStringAdvertiser name
callToActionStringCall to action text
extraJSONObjectExtra data
profileAdropNativeAdProfileProfile information
isBackfilledBooleanWhether it’s a backfill ad

Methods

MethodDescription
load()Load ad
destroy()Destroy ad

Usage Example

val nativeAd = AdropNativeAd(this, "YOUR_UNIT_ID")
nativeAd.listener = object : AdropNativeAdListener {
    override fun onAdReceived(ad: AdropNativeAd) {
        // Bind ad data
        headlineTextView.text = ad.headline
        bodyTextView.text = ad.body
        advertiserTextView.text = ad.advertiser
        ctaButton.text = ad.callToAction

        // Set ad to view
        nativeAdView.setNativeAd(ad)
    }

    override fun onAdFailedToReceive(ad: AdropNativeAd, errorCode: AdropErrorCode) {
        // Failed to receive ad
    }

    override fun onAdClick(ad: AdropNativeAd) {
        // Ad clicked
    }
}

nativeAd.load()

AdropNativeAdView

Container view for rendering native ads.

Constructor

AdropNativeAdView(context: Context, attrs: AttributeSet?)

Properties

PropertyTypeDescription
isEntireClickBooleanWhether entire area is clickable

Methods

MethodDescription
setIconView(view: View, listener: OnClickListener?)Set icon view (ImageView only)
setHeadLineView(view: View, listener: OnClickListener?)Set headline view (TextView only)
setBodyView(view: View)Set body view (TextView only)
setMediaView(view: AdropMediaView)Set media view
setAdvertiserView(view: View, listener: OnClickListener?)Set advertiser view (TextView only)
setCallToActionView(view: View)Set call to action button view
setProfileNameView(view: View, listener: OnClickListener?)Set profile name view
setProfileLogoView(view: View, listener: OnClickListener?)Set profile logo view (ImageView only)
setNativeAd(ad: AdropNativeAd)Set native ad
destroy()Destroy view

Usage Example

// Reference views from layout
val nativeAdView = findViewById<AdropNativeAdView>(R.id.native_ad_view)
val iconView = findViewById<ImageView>(R.id.ad_icon)
val headlineView = findViewById<TextView>(R.id.ad_headline)
val bodyView = findViewById<TextView>(R.id.ad_body)
val mediaView = findViewById<AdropMediaView>(R.id.ad_media)
val advertiserView = findViewById<TextView>(R.id.ad_advertiser)
val ctaView = findViewById<Button>(R.id.ad_cta)

// Set views
nativeAdView.setIconView(iconView)
nativeAdView.setHeadLineView(headlineView)
nativeAdView.setBodyView(bodyView)
nativeAdView.setMediaView(mediaView)
nativeAdView.setAdvertiserView(advertiserView)
nativeAdView.setCallToActionView(ctaView)

// Set after ad loads
nativeAd.listener = object : AdropNativeAdListener {
    override fun onAdReceived(ad: AdropNativeAd) {
        nativeAdView.setNativeAd(ad)
    }
}

AdropNativeAdListener

Interface for handling native ad events.

Methods

MethodDescription
onAdReceived(ad: AdropNativeAd)Ad received successfully
onAdClick(ad: AdropNativeAd)Ad clicked
onAdImpression(ad: AdropNativeAd)Ad impression (optional implementation)
onAdFailedToReceive(ad: AdropNativeAd, errorCode: AdropErrorCode)Failed to receive ad
All callbacks are called on the main thread (@UiThread).

AdropNativeAdProfile

Data class containing profile information for native ads.

Properties

PropertyTypeDescription
displayLogoStringProfile logo image URL
displayNameStringProfile name
linkStringProfile link URL

Usage Example

val profile = nativeAd.profile
profileNameTextView.text = profile.displayName
// Load profile logo into ImageView

AdropMediaView

View for displaying native ad media content.

Constructor

AdropMediaView(context: Context, attrs: AttributeSet?)

Description

The media view displays image or video content for native ads. It should be set through the setMediaView() method of AdropNativeAdView.

AdropInterstitialAd

Class for displaying interstitial ads.

Constructor

AdropInterstitialAd(context: Context, unitId: String)

Properties

PropertyTypeDescription
interstitialAdListenerAdropInterstitialAdListener?Interstitial ad event listener
contextContext?Context
unitIdStringAd unit ID
isLoadedBooleanWhether ad loading is complete
creativeIdStringCreative ID
txIdStringTransaction ID
campaignIdStringCampaign ID
isBackfilledBooleanWhether it’s a backfill ad

Methods

MethodDescription
load()Load ad
show(fromActivity: Activity)Show ad
destroy()Destroy ad

Usage Example

val interstitialAd = AdropInterstitialAd(this, "YOUR_UNIT_ID")

interstitialAd.interstitialAdListener = object : AdropInterstitialAdListener {
    override fun onAdReceived(ad: AdropInterstitialAd) {
        // Ad loaded, ready to show
        ad.show(this@MainActivity)
    }

    override fun onAdFailedToReceive(ad: AdropInterstitialAd, errorCode: AdropErrorCode) {
        // Failed to receive ad
    }

    override fun onAdDidDismissFullScreen(ad: AdropInterstitialAd) {
        // Ad closed
    }
}

// Load ad
interstitialAd.load()

AdropInterstitialAdListener

Interface for handling interstitial ad events.

Methods

MethodDescription
onAdReceived(ad: AdropInterstitialAd)Ad received successfully
onAdFailedToReceive(ad: AdropInterstitialAd, errorCode: AdropErrorCode)Failed to receive ad
onAdImpression(ad: AdropInterstitialAd)Ad impression (optional implementation)
onAdClicked(ad: AdropInterstitialAd)Ad clicked (optional implementation)
onAdWillPresentFullScreen(ad: AdropInterstitialAd)Full screen ad will present (optional implementation)
onAdDidPresentFullScreen(ad: AdropInterstitialAd)Full screen ad did present (optional implementation)
onAdWillDismissFullScreen(ad: AdropInterstitialAd)Full screen ad will dismiss (optional implementation)
onAdDidDismissFullScreen(ad: AdropInterstitialAd)Full screen ad did dismiss (optional implementation)
onAdFailedToShowFullScreen(ad: AdropInterstitialAd, errorCode: AdropErrorCode)Failed to show ad (optional implementation)
All callbacks are called on the main thread (@UiThread).

AdropRewardedAd

Class for displaying rewarded ads.

Constructor

AdropRewardedAd(context: Context, unitId: String)

Properties

PropertyTypeDescription
rewardedAdListenerAdropRewardedAdListener?Rewarded ad event listener
contextContext?Context
unitIdStringAd unit ID
isLoadedBooleanWhether ad loading is complete
creativeIdStringCreative ID
txIdStringTransaction ID
campaignIdStringCampaign ID
isBackfilledBooleanWhether it’s a backfill ad

Methods

MethodDescription
load()Load ad
show(fromActivity: Activity, userDidEarnRewardHandler: AdropUserDidEarnRewardHandler)Show ad with reward handler
destroy()Destroy ad

Usage Example

val rewardedAd = AdropRewardedAd(this, "YOUR_UNIT_ID")

rewardedAd.rewardedAdListener = object : AdropRewardedAdListener {
    override fun onAdReceived(ad: AdropRewardedAd) {
        // Ad loaded
        ad.show(this@MainActivity) { type, amount ->
            // Grant reward
            Log.d("Reward", "Type: $type, Amount: $amount")
        }
    }

    override fun onAdFailedToReceive(ad: AdropRewardedAd, errorCode: AdropErrorCode) {
        // Failed to receive ad
    }
}

rewardedAd.load()

AdropRewardedAdListener

Interface for handling rewarded ad events.

Methods

MethodDescription
onAdReceived(ad: AdropRewardedAd)Ad received successfully
onAdFailedToReceive(ad: AdropRewardedAd, errorCode: AdropErrorCode)Failed to receive ad
onAdImpression(ad: AdropRewardedAd)Ad impression (optional implementation)
onAdClicked(ad: AdropRewardedAd)Ad clicked (optional implementation)
onAdWillPresentFullScreen(ad: AdropRewardedAd)Full screen ad will present (optional implementation)
onAdDidPresentFullScreen(ad: AdropRewardedAd)Full screen ad did present (optional implementation)
onAdWillDismissFullScreen(ad: AdropRewardedAd)Full screen ad will dismiss (optional implementation)
onAdDidDismissFullScreen(ad: AdropRewardedAd)Full screen ad did dismiss (optional implementation)
onAdFailedToShowFullScreen(ad: AdropRewardedAd, errorCode: AdropErrorCode)Failed to show ad (optional implementation)
All callbacks are called on the main thread (@UiThread).

AdropUserDidEarnRewardHandler

Type alias called when a reward is granted.

Definition

typealias AdropUserDidEarnRewardHandler = (type: Int, amount: Int) -> Unit

Parameters

ParameterTypeDescription
typeIntReward type
amountIntReward amount

Usage Example

rewardedAd.show(this) { type, amount ->
    // Grant reward to user
    when (type) {
        0 -> grantCoins(amount)
        1 -> grantLives(amount)
    }
}

AdropPopupAd

Class for displaying popup ads.

Constructor

AdropPopupAd(context: Context, unitId: String)

Properties

PropertyTypeDescription
popupAdListenerAdropPopupAdListener?Popup ad event listener
closeListenerAdropPopupAdCloseListener?Popup close event listener
useCustomClickBooleanWhether to use custom click handling
closeTextColorInt?Close button text color
hideForTodayTextColorInt?”Don’t show today” text color
ctaTextColorInt?CTA button text color
backgroundColorInt?Background color
unitIdStringAd unit ID
creativeIdsList<String>Creative ID list
creativeIdStringCurrent creative ID
destinationURLStringDestination URL
isLoadedBooleanWhether ad loading is complete
txIdStringTransaction ID
campaignIdStringCampaign ID

Methods

MethodDescription
load()Load ad
show(activity: Activity)Show ad
open(url: String?)Open ad landing page
close()Close ad
destroy()Destroy ad

Usage Example

val popupAd = AdropPopupAd(this, "YOUR_UNIT_ID")

// Customize style
popupAd.closeTextColor = Color.WHITE
popupAd.backgroundColor = Color.parseColor("#80000000")

popupAd.popupAdListener = object : AdropPopupAdListener {
    override fun onAdReceived(ad: AdropPopupAd) {
        // Ad loaded
        ad.show(this@MainActivity)
    }

    override fun onAdFailedToReceive(ad: AdropPopupAd, errorCode: AdropErrorCode) {
        // Failed to receive ad
    }
}

popupAd.closeListener = object : AdropPopupAdCloseListener {
    override fun onTodayOffClicked(ad: AdropPopupAd) {
        // "Don't show today" clicked
    }
}

popupAd.load()

AdropPopupAdListener

Interface for handling popup ad events.

Methods

MethodDescription
onAdReceived(ad: AdropPopupAd)Ad received successfully
onAdFailedToReceive(ad: AdropPopupAd, errorCode: AdropErrorCode)Failed to receive ad
onAdImpression(ad: AdropPopupAd)Ad impression (optional implementation)
onAdClicked(ad: AdropPopupAd)Ad clicked (optional implementation)
onAdWillPresentFullScreen(ad: AdropPopupAd)Full screen ad will present (optional implementation)
onAdDidPresentFullScreen(ad: AdropPopupAd)Full screen ad did present (optional implementation)
onAdWillDismissFullScreen(ad: AdropPopupAd)Full screen ad will dismiss (optional implementation)
onAdDidDismissFullScreen(ad: AdropPopupAd)Full screen ad did dismiss (optional implementation)
onAdFailedToShowFullScreen(ad: AdropPopupAd, errorCode: AdropErrorCode)Failed to show ad (optional implementation)
All callbacks are called on the main thread (@UiThread).

AdropPopupAdCloseListener

Interface for handling popup ad close events.

Methods

MethodDescription
onClosed(ad: AdropPopupAd)Popup closed (optional implementation)
onDimClicked(ad: AdropPopupAd)Dim area clicked (optional implementation)
onTodayOffClicked(ad: AdropPopupAd)”Don’t show today” clicked (optional implementation)
All callbacks are called on the main thread (@UiThread).

AdropSplashAd

Class for displaying splash ads.

Constructor

AdropSplashAd(application: Application, shouldSkip: ((splashAd: AdropSplashAd) -> Boolean)?)

Parameters

ParameterTypeDescription
applicationApplicationApplication instance
shouldSkip((AdropSplashAd) -> Boolean)?Function to determine whether to skip splash ad (optional)

Properties

PropertyTypeDescription
splashAdListenerAdropSplashAdListener?Splash ad event listener
creativeIdStringCreative ID
isClosedBooleanWhether ad is closed
unitIdStringAd unit ID

Methods

MethodDescription
close()Close ad

Usage Example

// Need to add AdropSplashAdActivity to AndroidManifest.xml
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        val splashAd = AdropSplashAd(this) { ad ->
            // Skip under certain conditions
            false
        }

        splashAd.splashAdListener = object : AdropSplashAdListener {
            override fun onAdReceived(ad: AdropSplashAd) {
                // Ad received
            }

            override fun onAdClose(ad: AdropSplashAd, impressed: Boolean) {
                // Ad closed
            }
        }
    }
}

AdropSplashAdListener

Interface for handling splash ad events.

Methods

MethodDescription
onAdReceived(ad: AdropSplashAd)Ad received successfully (optional implementation)
onAdFailedToReceive(ad: AdropSplashAd, errorCode: AdropErrorCode)Failed to receive ad (optional implementation)
onAdImpression(ad: AdropSplashAd)Ad impression (optional implementation)
onAdClose(ad: AdropSplashAd, impressed: Boolean)Ad closed (required implementation)

Parameters

ParameterTypeDescription
impressedBooleanWhether the ad was actually impressed
All callbacks are called on the main thread (@UiThread).

AdropSplashAdView

Class for displaying splash ads as a view.

Constructor

AdropSplashAdView(context: Context, unitId: String, adRequestTimeout: Long = 1000L)
AdropSplashAdView(context: Context, attrs: AttributeSet?)

Properties

PropertyTypeDescription
listenerAdropSplashAdViewListener?Splash ad view event listener
displayDurationLongDisplay duration (Deprecated: Set in console)
creativeIdStringCreative ID
isClosedBooleanWhether ad is closed
unitIdStringAd unit ID
txIdStringTransaction ID
campaignIdStringCampaign ID

Methods

MethodDescription
load()Load ad

Usage Example

val splashAdView = AdropSplashAdView(this, "YOUR_UNIT_ID", adRequestTimeout = 2000L)

splashAdView.listener = object : AdropSplashAdViewListener {
    override fun onAdReceived(ad: AdropSplashAdView) {
        // Ad received
    }

    override fun onAdClose(ad: AdropSplashAdView, impressed: Boolean) {
        // Ad closed - navigate to main screen
        if (impressed) {
            // Ad was impressed
        }
        startMainActivity()
    }
}

// Add to layout
container.addView(splashAdView)
splashAdView.load()

AdropSplashAdViewListener

Interface for handling splash ad view events.

Methods

MethodDescription
onAdReceived(ad: AdropSplashAdView)Ad received successfully (optional implementation)
onAdFailedToReceive(ad: AdropSplashAdView, errorCode: AdropErrorCode)Failed to receive ad (optional implementation)
onAdImpression(ad: AdropSplashAdView)Ad impression (optional implementation)
onAdClose(ad: AdropSplashAdView, impressed: Boolean)Ad closed (required implementation)
All callbacks are called on the main thread (@UiThread).

AdropKey

Class that defines user property keys.

Constants

ConstantValueDescription
AGE"AGE"Age
BIRTH"BIRTH"Date of birth
GENDER"GDR"Gender

Usage Example

val params = AdropEventParam.Builder()
    .putInt(AdropKey.AGE, 25)
    .putString(AdropKey.GENDER, AdropValue.AdropGender.MALE)
    .putString(AdropKey.BIRTH, "19990101")
    .build()

AdropValue

Class that defines user property values.

Common Constants

ConstantValueDescription
UNKNOWN"U"Unknown

AdropBirth

Defines date of birth formats.
ConstantValueDescription
formatYear"yyyy"Year only (e.g., 1999)
formatYearMonth"yyyyMM"Year and month (e.g., 199901)
formatYearMonthDay"yyyyMMdd"Year, month, and day (e.g., 19990101)

AdropGender

Defines gender values.
ConstantValueDescription
MALE"M"Male
FEMALE"F"Female
OTHER"O"Other

Usage Example

val params = AdropEventParam.Builder()
    .putString(AdropKey.GENDER, AdropValue.AdropGender.MALE)
    .putString(AdropKey.BIRTH, "19990101") // Using formatYearMonthDay
    .build()

CreativeSize

Data class representing the size of a creative.

Properties

PropertyTypeDescription
widthDoubleWidth (dp)
heightDoubleHeight (dp)

Usage Example

val banner = AdropBanner(this, "YOUR_UNIT_ID")
banner.adSize = CreativeSize(320.0, 50.0)

AdropEventParam

Class for creating custom event parameters.

Builder Methods

MethodDescription
putBoolean(key: String, value: Boolean)Add Boolean value
putInt(key: String, value: Int)Add Int value
putFloat(key: String, value: Float)Add Float value
putString(key: String, value: String)Add String value
putLong(key: String, value: Long)Add Long value (max: 9007199254740991)
build()Create AdropEventParam instance

Usage Example

val params = AdropEventParam.Builder()
    .putString(AdropKey.GENDER, AdropValue.AdropGender.MALE)
    .putInt(AdropKey.AGE, 25)
    .putString(AdropKey.BIRTH, "19990101")
    .build()
The value passed to putLong() cannot exceed JavaScript’s MAX_SAFE_INTEGER (9007199254740991).