Adrop
The main class of the Adrop SDK. Handles SDK initialization and global settings.
Static Methods
| Method | Description |
|---|
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): Boolean | Handles Adrop deep links. |
openQuest(context: Context, channel: String, path: String?) | Opens the Adrop Quest page. |
Static Properties
| Property | Type | Description |
|---|
isProduction | Boolean | Whether in production mode |
sdkVersion | String | SDK 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
| Value | Description |
|---|
LIGHT | Light mode |
DARK | Dark mode |
AUTO | Follow system settings automatically (default) |
Usage Example
Adrop.setTheme(AdropTheme.DARK)
AdropErrorCode
Error codes that may occur when loading and displaying ads.
Values
| Error Code | Description |
|---|
ERROR_CODE_NETWORK | Network error |
ERROR_CODE_INTERNAL | Internal error |
ERROR_CODE_INITIALIZE | SDK initialization error |
ERROR_CODE_INVALID_UNIT | Invalid ad unit ID |
ERROR_CODE_NOT_TARGET_COUNTRY | Not in target country |
ERROR_CODE_AD_INACTIVE | Inactive ad |
ERROR_CODE_AD_NO_FILL | No ad available to display |
ERROR_CODE_AD_LOAD_DUPLICATED | Duplicate ad load request |
ERROR_CODE_AD_LOADING | Ad is loading |
ERROR_CODE_AD_EMPTY | Ad is empty |
ERROR_CODE_AD_SHOWN | Ad has already been shown |
ERROR_CODE_AD_HIDE_FOR_TODAY | ”Don’t show today” is set |
ERROR_CODE_ACCOUNT_USAGE_LIMIT_EXCEEDED | Account usage limit exceeded |
ERROR_CODE_LANDSCAPE_UNSUPPORTED | Landscape 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
| Property | Type | Description |
|---|
listener | AdropBannerListener? | Banner event listener |
shouldAdjustHtmlStyle | Boolean | Whether to auto-adjust HTML style (default: false) |
useCustomClick | Boolean | Whether to use custom click handling (default: false) |
adSize | CreativeSize? | Banner size for backfill ads (dp) |
contextId | String | Context ID |
creativeId | String | Creative ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
destinationURL | String | Destination URL |
creativeSize | CreativeSize | Creative size |
isBackfilled | Boolean | Whether it’s a backfill ad |
Methods
| Method | Description |
|---|
setUnitId(unitId: String) | Set ad unit ID |
getUnitId(): String | Get 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
| Method | Description |
|---|
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
| Property | Type | Description |
|---|
listener | AdropNativeAdListener? | Native ad event listener |
useCustomClick | Boolean | Whether to use custom click handling |
context | Context | Context |
isLoaded | Boolean | Whether ad loading is complete |
isDestroyed | Boolean | Whether ad is destroyed |
creativeId | String | Creative ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
creativeSize | CreativeSize | Creative size |
icon | String | Icon image URL |
cover | String | Cover image URL |
headline | String | Headline |
body | String | Body text |
creative | String | Creative URL |
asset | String | Asset URL |
destinationURL | String | Destination URL |
advertiserURL | String | Advertiser URL |
accountTag | JSONObject | Account tag |
creativeTag | JSONObject | Creative tag |
advertiser | String | Advertiser name |
callToAction | String | Call to action text |
extra | JSONObject | Extra data |
profile | AdropNativeAdProfile | Profile information |
isBackfilled | Boolean | Whether it’s a backfill ad |
Methods
| Method | Description |
|---|
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
| Property | Type | Description |
|---|
isEntireClick | Boolean | Whether entire area is clickable |
Methods
| Method | Description |
|---|
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
| Method | Description |
|---|
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
| Property | Type | Description |
|---|
displayLogo | String | Profile logo image URL |
displayName | String | Profile name |
link | String | Profile link URL |
Usage Example
val profile = nativeAd.profile
profileNameTextView.text = profile.displayName
// Load profile logo into ImageView
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
| Property | Type | Description |
|---|
interstitialAdListener | AdropInterstitialAdListener? | Interstitial ad event listener |
context | Context? | Context |
unitId | String | Ad unit ID |
isLoaded | Boolean | Whether ad loading is complete |
creativeId | String | Creative ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
isBackfilled | Boolean | Whether it’s a backfill ad |
Methods
| Method | Description |
|---|
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
| Method | Description |
|---|
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
| Property | Type | Description |
|---|
rewardedAdListener | AdropRewardedAdListener? | Rewarded ad event listener |
context | Context? | Context |
unitId | String | Ad unit ID |
isLoaded | Boolean | Whether ad loading is complete |
creativeId | String | Creative ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
isBackfilled | Boolean | Whether it’s a backfill ad |
Methods
| Method | Description |
|---|
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
| Method | Description |
|---|
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
| Parameter | Type | Description |
|---|
type | Int | Reward type |
amount | Int | Reward amount |
Usage Example
rewardedAd.show(this) { type, amount ->
// Grant reward to user
when (type) {
0 -> grantCoins(amount)
1 -> grantLives(amount)
}
}
Class for displaying popup ads.
Constructor
AdropPopupAd(context: Context, unitId: String)
Properties
| Property | Type | Description |
|---|
popupAdListener | AdropPopupAdListener? | Popup ad event listener |
closeListener | AdropPopupAdCloseListener? | Popup close event listener |
useCustomClick | Boolean | Whether to use custom click handling |
closeTextColor | Int? | Close button text color |
hideForTodayTextColor | Int? | ”Don’t show today” text color |
ctaTextColor | Int? | CTA button text color |
backgroundColor | Int? | Background color |
unitId | String | Ad unit ID |
creativeIds | List<String> | Creative ID list |
creativeId | String | Current creative ID |
destinationURL | String | Destination URL |
isLoaded | Boolean | Whether ad loading is complete |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
Methods
| Method | Description |
|---|
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()
Interface for handling popup ad events.
Methods
| Method | Description |
|---|
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).
Interface for handling popup ad close events.
Methods
| Method | Description |
|---|
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
| Parameter | Type | Description |
|---|
application | Application | Application instance |
shouldSkip | ((AdropSplashAd) -> Boolean)? | Function to determine whether to skip splash ad (optional) |
Properties
| Property | Type | Description |
|---|
splashAdListener | AdropSplashAdListener? | Splash ad event listener |
creativeId | String | Creative ID |
isClosed | Boolean | Whether ad is closed |
unitId | String | Ad unit ID |
Methods
| Method | Description |
|---|
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
| Method | Description |
|---|
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
| Parameter | Type | Description |
|---|
impressed | Boolean | Whether 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
| Property | Type | Description |
|---|
listener | AdropSplashAdViewListener? | Splash ad view event listener |
displayDuration | Long | Display duration (Deprecated: Set in console) |
creativeId | String | Creative ID |
isClosed | Boolean | Whether ad is closed |
unitId | String | Ad unit ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
Methods
| Method | Description |
|---|
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
| Method | Description |
|---|
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
| Constant | Value | Description |
|---|
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
| Constant | Value | Description |
|---|
UNKNOWN | "U" | Unknown |
AdropBirth
Defines date of birth formats.
| Constant | Value | Description |
|---|
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.
| Constant | Value | Description |
|---|
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
| Property | Type | Description |
|---|
width | Double | Width (dp) |
height | Double | Height (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
| Method | Description |
|---|
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).