Skip to main content

3. API Description

3.1 AdListener

Method NameDescription
onAdLoaded()Callback when ad loading is completed, applicable to Splash, Interstitial, Banner, Reward ads
onAdLoaded(List<TaNativeInfo> adInfos)Callback when ad loading is completed, applicable to Native, Icon ads
onError(TaErrorCode taErrorCode)Callback for errors during ad request or ad filling process
onAdShow()Callback for successful ad display, applicable to Splash, Interstitial, Banner, Reward ads
onNativeAdShow(TaNativeInfo taNativeInfo)Callback for successful ad display, applicable to Native, Icon ads
onAdShowError(TaErrorCode adError)Callback for failed ad display, applicable to Splash, Interstitial, Reward ads
onAdClicked()Callback for ad click, applicable to Splash, Interstitial, Banner, Reward ads
onNativeAdClick(TaNativeInfo taNativeInfo)Callback for ad click, applicable to Native, Icon ads
onAdClosed()Callback for personalized ad closure, applicable to Interstitial, Splash ads
onAdClosed(TBannerView bannerView)Callback for personalized ad closure, applicable to Banner ads
onAdClosed(TaNativeInfo taNativeInfo)Callback for personalized ad closure, applicable to Native, Icon ads
onTimeOut()Callback for ad loading timeout

3.2 TBannerView

Method NameDescription
TBannerView(Context context, String placementId)Constructor
TBannerView(Context context, AttributeSet attrs)Constructor
TBannerView(Context context, AttributeSet attrs, int defStyleAttr)Constructor
setPlacementId(String placementId)Sets the ad unit ID
setListener(AdListener listener)Sets the listener for ad request steps
loadAd()Starts requesting ads
show()Displays the ad
destroy()Releases ad resources
setAdLoadScenes(@Nullable String gameName, @Nullable String gameScene, @Nullable Map<String,Object> extInfo)(Aha platform specific) Sets the ad loading scene. gameName: corresponding game's appKey; gameScene: corresponding game scene; extInfo: custom information from the media (optional). Call before requesting ads
getGameName()Gets the game name
getGameScene()Gets the game scene
getExtInfo()Gets custom parameters
isOfflineAd()Checks if it's an offline ad
getAdSource()Gets the ad source
isReady()Checks if the ad is ready. true: indicates the ad is loaded successfully and within the delivery period, can call show() to display the ad; false: indicates the ad is not ready yet
isAdValid()Checks if the ad is within the delivery period. Recommendation: Please use isReady() instead as soon as possible, this method will be removed in future versions
getFillAdType()Gets the type of filled ad. 1: offline ad, 0: online ad, -1: no fill
setRequest(AdRequest aRequest)Sets the ad request entity
getRequest()Gets the ad request entity
setHideAdCloseView(boolean isHideAdCloseView)Sets whether to hide the ad close button
setCurrActivityFullscreen(boolean isCurrActivityFullscreen)Sets whether the current display Activity is in fullscreen mode
setDefaultFillTimeoutDuration(int defaultFillTimeoutDuration)Sets the default fill timeout duration for the current ad request, cloud control configuration takes precedence if available
setContainVulgarContent(boolean isContainVulgarContent)Sets whether the host's current scene for displaying ads contains sensitive content, if yes, some brand ads will not be filled
isMatchVulgarBrand()After successful ad request, checks if the current ad matches filtering rules. true: not recommended for display in scenes with sensitive content, false: can be displayed
setCloseDirectlyWithoutJumping(boolean isCloseDirectly)Banner ad closes directly without redirection when the close button is clicked

3.3 TInterstitial

Method NameDescription
TInterstitial(String placementId)Constructor
setPlacementId(String placementId)Sets the ad unit ID
setListener(AdListener listener)Sets the listener for ad request steps
loadAd()Starts requesting ads
show()Displays the ad
destroy()Releases ad resources
setAdLoadScenes(@Nullable String gameName, @Nullable String gameScene, @Nullable Map<String,Object> extInfo)(Aha platform specific) Sets the ad loading scene. gameName: corresponding game's appKey; gameScene: corresponding game scene; extInfo: custom information from the media (optional). Call before requesting ads
getGameName()Gets the game name
getGameScene()Gets the game scene
getExtInfo()Gets custom parameters
isOfflineAd()Checks if it's an offline ad
getAdSource()Gets the ad source
getFillAdType()Gets the type of filled ad. 1: offline ad, 0: online ad, -1: no fill
isReady()Checks if the ad is ready. true: indicates the ad is loaded successfully and within the delivery period, can call show() to display the ad; false: indicates the ad is not ready yet
isAdValid()Checks if the ad is within the delivery period. Recommendation: Please use isReady() instead as soon as possible, this method will be removed in future versions
setRequest(AdRequest aRequest)Sets the ad request entity
getRequest()Gets the ad request entity
setCurrActivityFullscreen(boolean isCurrActivityFullscreen)Sets whether the current display Activity is in fullscreen mode
setDefaultFillTimeoutDuration(int defaultFillTimeoutDuration)Sets the default fill timeout duration for the current ad request, cloud control configuration takes precedence if available
setContainVulgarContent(boolean isContainVulgarContent)Sets whether the host's current scene for displaying ads contains sensitive content, if yes, some brand ads will not be filled
isMatchVulgarBrand()After successful ad request, checks if the current ad matches filtering rules. true: not recommended for display in scenes with sensitive content, false: can be displayed

3.4 TSplash

Method NameDescription
TSplash(Context context, String placementId)Constructor
setPlacementId(String placementId)Sets the ad unit ID
setListener(AdListener listener)Sets the listener for ad request steps
setSkipListener(OnSkipListener listener)Sets the listener for skip clicks
loadAd()Starts requesting ads
show()Displays the ad
destroy()Releases ad resources
isDestroy()Checks if already destroyed
setLogoLayout(View logoView)Sets the logo to be displayed
setAdLoadScenes(@Nullable String gameName, @Nullable String gameScene, @Nullable Map<String,Object> extInfo)(Aha platform specific) Sets the ad loading scene. gameName: corresponding game's appKey; gameScene: corresponding game scene; extInfo: custom information from the media (optional). Call before requesting ads
getGameName()Gets the game name
getGameScene()Gets the game scene
getExtInfo()Gets custom parameters
isOfflineAd()Checks if it's an offline ad
getAdSource()Gets the ad source
getFillAdType()Gets the type of filled ad. 1: offline ad, 0: online ad, -1: no fill
isReady()Checks if the ad is ready. true: indicates the ad is loaded successfully and within the delivery period, can call show() to display the ad; false: indicates the ad is not ready yet
isAdValid()Checks if the ad is within the delivery period. Recommendation: Please use isReady() instead as soon as possible, this method will be removed in future versions
setRequest(AdRequest aRequest)Sets the ad request entity
getRequest()Gets the ad request entity
setCurrActivityFullscreen(boolean isCurrActivityFullscreen)Sets whether the current display Activity is in fullscreen mode
setDefaultFillTimeoutDuration(int defaultFillTimeoutDuration)Sets the default fill timeout duration for the current ad request, cloud control configuration takes precedence if available
setContainVulgarContent(boolean isContainVulgarContent)Sets whether the host's current scene for displaying ads contains sensitive content, if yes, some brand ads will not be filled
isMatchVulgarBrand()After successful ad request, checks if the current ad matches filtering rules. true: not recommended for display in scenes with sensitive content, false: can be displayed
setEnableFullscreen(boolean value)Activity mode splash screen supports fullscreen style, hiding status bar and navigation bar. Default false (disabled)
setLiteInit(String appId, boolean athenaDebug)This method is used to quickly load and display offline or built-in splash ads. It must be used in conjunction with the placement configuration fillTimeoutDuration=0ms

3.5 TSplashView

Method NameDescription
TSplashView(Context context, String placementId)Constructor
TSplashView(Context context, AttributeSet attrs)Constructor
TSplashView(Context context, AttributeSet attrs, int defStyleAttr)Constructor
setPlacementId(String placementId)Sets the ad unit ID
setListener(AdListener listener)Sets the listener for ad request steps
setSkipListener(OnSkipListener listener)Sets the listener for skip clicks
loadAd()Starts requesting ads
show()Displays the ad
destroy()Releases ad resources
setLogoLayout(View logoView)Sets the logo to be displayed
setAdLoadScenes(@Nullable String gameName, @Nullable String gameScene, @Nullable Map<String,Object> extInfo)(Aha platform specific) Sets the ad loading scene. gameName: corresponding game's appKey; gameScene: corresponding game scene; extInfo: custom information from the media (optional). Call before requesting ads
getGameName()Gets the game name
getGameScene()Gets the game scene
getExtInfo()Gets custom parameters
isOfflineAd()Checks if it's an offline ad
getAdSource()Gets the ad source
getFillAdType()Gets the type of filled ad. 1: offline ad, 0: online ad, -1: no fill
isReady()Checks if the ad is ready. true: indicates the ad is loaded successfully and within the delivery period, can call show() to display the ad; false: indicates the ad is not ready yet
isAdValid()Checks if the ad is within the delivery period. Recommendation: Please use isReady() instead as soon as possible, this method will be removed in future versions
setRequest(AdRequest aRequest)Sets the ad request entity
getRequest()Gets the ad request entity
setCurrActivityFullscreen(boolean isCurrActivityFullscreen)Sets whether the current display Activity is in fullscreen mode
setDefaultFillTimeoutDuration(int defaultFillTimeoutDuration)Sets the default fill timeout duration for the current ad request, cloud control configuration takes precedence if available
setContainVulgarContent(boolean isContainVulgarContent)Sets whether the host's current scene for displaying ads contains sensitive content, if yes, some brand ads will not be filled
isMatchVulgarBrand()After successful ad request, checks if the current ad matches filtering rules. true: not recommended for display in scenes with sensitive content, false: can be displayed
setLiteInit(String appId, boolean athenaDebug)This method is used to quickly load and display offline or built-in splash ads. It must be used in conjunction with the placement configuration fillTimeoutDuration=0ms

3.6 TNative

Method NameDescription
TNative(String placementId)Constructor
setPlacementId(String placementId)Sets the ad unit ID
setListener(AdListener listener)Sets the listener for ad request steps
loadAd()Starts requesting ads
destroy()Releases ad resources
setAdCount(int adCount)Sets how many ads to load at once
setLoadIcon(boolean isLoadIcon)Sets whether the current ad unit uses ICON type. (Note: ICON and NATIVE ads have the same integration method but different ad types)
registerViews(@NonNull ViewGroup view, List<View> adContains, TaNativeInfo taNativeInfo)Registers listener events for ad-related Views
registerViews(@NonNull ViewGroup view, TaNativeInfo taNativeInfo)Template rendering
getAdChoicesView(Context context, TaNativeInfo taNativeInfo)Gets AdChoicesView, can be used to customize display coordinates
getAdCloseView(Context context)Gets close button, can be used to customize display coordinates
setAdLoadScenes(@Nullable String gameName, @Nullable String gameScene, @Nullable Map<String,Object> extInfo)(Aha platform specific) Sets the ad loading scene. gameName: corresponding game's appKey; gameScene: corresponding game scene; extInfo: custom information from the media (optional). Call before requesting ads
getGameName()Gets the game name
getGameScene()Gets the game scene
getExtInfo()Gets custom parameters
isReady(TaNativeInfo taNativeInfo)Checks if the ad is ready. true: indicates the ad is loaded successfully and within the delivery period, can call show() to display the ad; false: indicates the ad is not ready yet
isAdValid(TaNativeInfo taNativeInfo)Checks if the ad is within the delivery period. Recommendation: Please use isReady() instead as soon as possible, this method will be removed in future versions
isLoading()Checks if ads are currently loading
setRequest(AdRequest aRequest)Sets the ad request entity
getRequest()Gets the ad request entity
setCurrActivityFullscreen(boolean isCurrActivityFullscreen)Sets whether the current display Activity is in fullscreen mode
setDefaultFillTimeoutDuration(int defaultFillTimeoutDuration)Sets the default fill timeout duration for the current ad request, cloud control configuration takes precedence if available
setContainVulgarContent(boolean isContainVulgarContent)Sets whether the host's current scene for displaying ads contains sensitive content, if yes, some brand ads will not be filled

3.7 TaNativeInfo

Method NameDescription
getTitle()Gets title
getRating()Gets rating information (optional)
getCtatext()Gets button text (optional)
getDescription()Gets ad description (optional)
destroy()Releases resources
isMatchVulgarBrand()After successful ad request, checks if the current ad matches filtering rules. true: not recommended for display in scenes with sensitive content, false: can be displayed
getAdFormat()Return value: 2 indicates a native task-type ad, while values other than 2 indicate regular type ads.

3.8 TNativeView

Method NameDescription
setMediaView(MediaView mediaView, ImageView.ScaleType scaleType)Sets main image
setIconView(ImageView view)Sets icon
setAdCloseView(AdCloseView adCloseView)Sets ad close button
setAdChoiceView(AdChoicesView adChoicesView)Sets ad identifier
setUseListMode(boolean useListMode)Call this method and pass true when used in RecyclerView layout, default false
setAdBadgeView(AdBadgeView view)Ad badge (AD), recommended for media complying with RU (Russia) ad regulations
setAdDisclaimerView(AdDisclaimerView adDisclaimerView)Ad disclaimer, recommended for media complying with RU (Russia) ad regulations
destroy()Releases resources

3.9 TRewarded

Method NameDescription
TRewarded(String placementId)Constructor
setAdListener(AdListener listener)Sets the listener for ad request steps
loadAd()Starts requesting ads
show()Displays the ad
destroy()Releases ad resources
setAdLoadScenes(@Nullable String gameName, @Nullable String gameScene, @Nullable Map<String,Object> extInfo)(Aha platform specific) Sets the ad loading scene. gameName: corresponding game's appKey; gameScene: corresponding game scene; extInfo: custom information from the media (optional). Call before requesting ads
getGameName()Gets the game name
getGameScene()Gets the game scene
getExtInfo()Gets custom parameters
isReady()Checks if the ad is ready. true: indicates the ad is loaded successfully and within the delivery period, can call show() to display the ad; false: indicates the ad is not ready yet
isAdValid()Checks if the ad is within the delivery period. Recommendation: Please use isReady() instead as soon as possible, this method will be removed in future versions
setRequest(AdRequest aRequest)Sets the ad request entity
getRequest()Gets the ad request entity
setDefaultFillTimeoutDuration(int defaultFillTimeoutDuration)Sets the default fill timeout duration for the current ad request, cloud control configuration takes precedence if available
setContainVulgarContent(boolean isContainVulgarContent)Sets whether the host's current scene for displaying ads contains sensitive content, if yes, some brand ads will not be filled

3.10 HisavanaAdJsBridge

Function: Assists JS SDK page to open PlayStore half-screen

 webView.getSettings().setCacheMode(LOAD_NORMAL);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);//Set permissions for interaction with Js
webView.addJavascriptInterface(new HisavanaAdJsBridge(),HisavanaAdJsBridge.INTERFACE_NAME);

Description: Sets up Android-JS interaction functionality

webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return goToNext(request.getUrl().toString());
}
return super.shouldOverrideUrlLoading(view,request);
}
});

Description: Overrides the shouldOverrideUrlLoading method of WebViewClient to handle redirection.

3.11 AdRequest

Method NameDescription
getRequestId()Gets request ID
setRequestId(String requestId)Sets request ID
getRequestType()Gets ad request timing, 1: media request; 5: cold start; 6: network change; 7: ad return
setRequestType(int requestType)Sets ad request timing
getTriggerId()Gets trigger ID
setTriggerId(String triggerId)Sets trigger ID
getInfo()Gets ad second price, unit: cents
setInfo(double info)Sets ad second price, unit: cents

3.12 OnSkipListener

Method NameDescription
onClick()Callback for click
onTimeEnd()Callback for countdown end

3.13 AdManager

Method NameDescription
setScreenOrientation(int orientation)Sets screen orientation for ad pages (currently effective for interstitial, banner, H5 pages)
getScreenOrientation()Returns screen orientation
setRewardedCompletionToastEnabled(boolean isEnabled)Set the toast prompt switch for the new interstitial and rewarded ad styles after reward completion. true: enabled, false: disabled, default is true