5. Notes:
6. Access process suggestions:
ATBannerView: The loading class of Banner ads is also a View that displays Banner ads
Method | Parameters | Description |
---|---|---|
setPlacementId | (String bannerTakuPlacementID) | Set Banner's advertising slot id, where bannerTakuPlacementID is created through the Taku background< span style="color: rgb(44, 62, 80);">banner ad slot obtained. (Must be set) |
loadAd | - | Banner ad loading |
Ad loading display:
ATBannerView mBannerView = new ATBannerView(BannerAdActivity.this);
mBannerView.setPlacementId(bannerTakuPlacementID);
mBannerView.loadAd();
ATBannerView:
Method | Parameters | Description |
---|---|---|
(Deprecated since v6.3.10) Set advertising scenes (for subsequent ads), please refer to Advertising scenes | ||
setShowConfig | (ATShowConfig showConfig) | (v6.3.10+) Set advertising scenes (for subsequent ads) showConfig: You can pass in additional parameters during display, as follows 1.ATShowConfig#showCustomExt(String showCustomExt): You can pass in custom parameters during display, and the parameters passed in will be returned through ATAdInfo#getShowCustomExt() 2.ATShowConfig#scenarioId(String scenarioId): Advertising scenarios can be passed in, the same as getNativeAd(String scenario) |
Scene example:
mBannerView.setScenario("your scenarioID");
ATBannerView:
Method | Parameters | Description |
---|---|---|
setLocalExtra | (Map | Set local parameters |
1. It is best to choose the same or close proportion of the sizes of each advertising source under the Banner ad slot
2. Call the load method to load Before advertising, you need to pass in the width and height through setLocalExtra()
ATBannerView mBannerView = new ATBannerView(BannerAdActivity.this);
mBannerView.setPlacementId(bannerTakuPlacementID);
int width = getResources().getDisplayMetrics().widthPixels;//Set a width value, such as screen width
int height = (int) (width / (320 / 50f));//Convert height values proportionally
Map localMap = new HashMap<>();
localMap.put(ATAdConst.KEY.AD_WIDTH, width);
localMap.put(ATAdConst.KEY.AD_HEIGHT, height);
mBannerView.setLocalExtra(localMap);
mBannerView.loadAd();
If you use the above code, Banner sometimes appears If the height is high or sometimes low, please use the following sample code to limit the height:
int width = getResources().getDisplayMetrics().widthPixels;//Set a width value, such as screen width
int height = (int) (width / (320 / 50f));//Must be consistent with the banner ad source width to height ratio configured in the Taku backend, assuming a size of 320x50
mBannerView.setLayoutParams(new FrameLayout.LayoutParams(width, height));
...
ATBannerView:
Method | Parameter | Description |
---|---|---|
destroy | - | Banner ad destruction (move Executed when dividing) |
1.Banner can be removed under the following circumstances
2.Note: When calling back OnBannerClose(), if not Manually calling the code to remove it will automatically refresh the Banner ad
ATBannerView:
Method | Parameters | Description |
---|---|---|
checkAdStatus | - | Get the status object ATAdStatusInfo of the current advertising slot. See the API description of the ATAdStatusInfo object below |
checkValidAdCaches | - | Query all cached information of the current advertising slot ATAdInfo object ATAdInfo: advertising information object, which can distinguish advertising platforms and mainly contains the id information of third-party aggregation platforms See ATAdInfo information description |
ATAdStatusInfo: Status object of the ad slot
Parameter | Description | |
---|---|---|
isLoading | - | Judgement Whether the current ad slot is loading ads |
isReady | - | Determine whether there are ads that can be displayed in the current ad slot |
getATTopAdInfo | - |
ATBannerView:
Method | Parameters | Description |
---|---|---|
setBannerAdListener | (ATBannerListener listener) | Set Banner advertisement listening callback, where ATBannerListener is the interface class that needs to implement advertisement event callback |
setAdDownloadListener | (ATAppDownloadListener listener) | Set download status monitoring callback listener: Event callback monitoring for download status Currently, only the following platforms are supported: CSJ |
setAdSourceStatusListener | (ATAdSourceStatusListener listener) | Set up an ad source level event listening callback, where ATAdSourceStatusListener is the interface class that needs to implement the ad source level event callback, as shown in ATAdSourceStatusListener Description |
ATBannerListener: It is a banner advertisement event callback listening
Method | Parameters | Description |
---|---|---|
onBannerLoaded | - | Callback for successful advertisement loading |
onBannerFailed | (AdError error) | Advertisement loading failure callback, all error information can be obtained through AdError. getFullErrorInfo(), please refer to AdError Note: It is prohibited to retry the loading method of advertisements in this callback, otherwise it will cause many useless requests and may cause the application to lag |
onBannerShow | (ATAdInfo atAdInfo) | Advertising display callback ATAdInfo: The information object of an advertisement, which can distinguish between advertising platforms and mainly includes the ID information of third-party aggregation platforms See ATAdInfo information description |
onBannerClicked | (ATAdInfo atAdInfo) | Ad click callback The parameter meaning is the same as above |
onBannerClose | (ATAdInfo atAdInfo) | Ad closure callback (some advertising platforms have this callback) The parameter meaning is the same as above |
onBannerAutoRefreshed | (ATAdInfo atAdInfo) | Automatic refresh callback for advertisements The parameter meaning is the same as above |
onBannerAutoRefreshFail | (AdError error) | Automatic refresh failure callback for advertisements The parameter meaning is the same as above |
Listening Example:
mBannerView.setBannerAdListener(new ATBannerListener() {
@Override
public void onBannerLoaded() {
}
@Override
public void onBannerFailed(AdError adError) {
//Note: It is prohibited to retry the loading method of advertisements in this callback, otherwise it will cause many useless requests and may cause the application to lag
//AdError, please refer to https://docs.toponad.com/#/zh -Cn/android/android_ Doc/android_ Test? Id=aderror
Log.e(TAG, "onBannerFailed:" + adError.getFullErrorInfo());
}
@Override
public void onBannerClicked(ATAdInfo atAdInfo) {
}
@Override
public void onBannerShow(ATAdInfo atAdInfo) {
//ATAdInfo can distinguish between advertising platforms and obtain advertising space IDs for advertising platforms
//please refer tohttps://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_callback_access?id=callback_info
}
@Override
public void onBannerClose(ATAdInfo atAdInfo) {
if (mBannerView != null && mBannerView.getParent() != null) {
((ViewGroup) mBannerView.getParent()).removeView(mBannerView);
}
}
@Override
public void onBannerAutoRefreshed(ATAdInfo atAdInfo) {
}
@Override
public void onBannerAutoRefreshFail(AdError adError) {
//AdError:https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
Log.e(TAG, "onBannerAutoRefreshFail:" + adError.getFullErrorInfo());
}
});
ATBannerExListener: Inherited from ATBannerListener, with the same method as ATBannerListener. Additional callback instructions are as follows:
Method | Parameters | Description |
---|---|---|
onDeeplinkCallback | (boolean isRefresh, ATAdInfo atAdInfo, boolean isSuccess) | Deeplink callback for Adx and OnlineApi advertisements IsRefresh: Is it an automatic refresh IsSuccess: Is it successful |
onDownloadConfirm | (Context context, ATAdInfo atAdInfo, View clickView, ATNetworkConfirmInfo networkConfirmInfo) | Callback method when clicking download for application advertisements. ATNetworkConfirmInfo: Callback information provided by third-party advertising platforms (currently only available in GDTDownloadFirmInfo from Youlianghui) ATAdInfo: The information object of an advertisement, which can distinguish between advertising platforms and mainly includes the ID information of third-party aggregation platforms See ATAdInfo information description |
ATAppDownloadListener: (Only supported by SDK in China) Event callback listening for download status
Currently, only the following platforms are supported: csj
Method | Parameters | Description |
---|---|---|
onDownloadStart | (ATAdInfo atAdInfo, long totalBytes, long currBytes, String fileName, String appName) | Start downloading callback ATAdInfo: The information object of an advertisement, which can distinguish between advertising platforms and mainly includes the ID information of third-party aggregation platforms. Please refer to the ATAdInfo information description TotalBytes: Total file size (in bytes) CurrBytes: The current downloaded size (in bytes) FileName: File name AppName: The application name corresponding to the file |
onDownloadUpdate | (ATAdInfo atAdInfo, long totalBytes, long currBytes, String fileName, String appName) | Download progress update callback The parameter meaning is the same as above |
onDownloadPause | (ATAdInfo atAdInfo, long totalBytes, long currBytes, String fileName, String appName) | Pause download callback The parameter meaning is the same as above |
onDownloadFinish | (ATAdInfo adInfo, long totalBytes, String fileName, String appName) | Download completion callback The parameter meaning is the same as above |
onDownloadFail | (ATAdInfo adInfo, long totalBytes, long currBytes, String fileName, String appName) | Download failure callback The parameter meaning is the same as above |
onInstalled | (ATAdInfo adInfo, String fileName, String appName) | APK installation completion callback The parameter meaning is the same as above |
ATBannerView mBannerView = new ATBannerView(BannerAdActivity.this);
mBannerView.setPlacementId(bannerTakuPlacementID);
int width = getResources().getDisplayMetrics().widthPixels;//Set a width value, such as screen width
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
//If there is a situation where the Banner is sometimes high and sometimes low, please use this code
//Float ratio=320/50f// Must be consistent with the banner ad source width to height ratio configured in the Taku backend, assuming a size of 320x50
//Int width=getResources(). getDisplayMetrics(). widthPixels// Set a width value, such as screen width
//Int height=(int) (width/ratio);
mBannerView.setLayoutParams(new FrameLayout.LayoutParams(width, height));
frameLayout.addView(mBannerView);
mBannerView.setBannerAdListener(new ATBannerListener() {
@Override
public void onBannerLoaded() {
}
@Override
public void onBannerFailed(AdError adError) {
//Note: It is prohibited to retry the loading method of advertisements in this callback, otherwise it will cause many useless requests and may cause the application to lag
//AdError, please refer to https://docs.toponad.com/#/zh -Cn/android/android_ Doc/android_ Test? Id=aderror
Log.e(TAG, "onBannerFailed:" + adError.getFullErrorInfo());
}
@Override
public void onBannerClicked(ATAdInfo atAdInfo) {
}
@Override
public void onBannerShow(ATAdInfo atAdInfo) {
//ATAdInfo can distinguish between advertising platforms and obtain advertising space IDs for advertising platforms
//please refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_callback_access?id=callback_info
}
@Override
public void onBannerClose(ATAdInfo atAdInfo) {
if (mBannerView != null && mBannerView.getParent() != null) {
((ViewGroup) mBannerView.getParent()).removeView(mBannerView);
}
}
@Override
public void onBannerAutoRefreshed(ATAdInfo atAdInfo) {
}
@Override
public void onBannerAutoRefreshFail(AdError adError) {
//AdError:https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
Log.e(TAG, "onBannerAutoRefreshFail:" + adError.getFullErrorInfo());
}
});
//Scenario ID is passed into the background scene management to display data
mBannerView.setScenario("your scenarioID");
mBannerView.loadAd();
For detailed banner advertising example code, please refer to:BannerAdActivity class for Demo
The Taku SDK supports Admob's adaptive banners, including adaptive anchored banners and adaptive large-sized banners. It is recommended to use adaptive anchored banners. Developers need to use the following code to set the type of adaptive banner, which screen orientation to adapt to, and the width of the banner (in px)
...
Map localExtra = new HashMap<>();
//Since v5.7.0, Admob Adaptive Banner (adaptive anchored banner, adaptive large-sized banner)
localExtra.put(AdmobATConst.ADAPTIVE_TYPE, AdmobATConst.ADAPTIVE_ANCHORED);//Adaptive anchoring banner
//localExtra.put(AdmobATConst.ADAPTIVE_TYPE, AdmobATConst.ADAPTIVE_INLINE);//Adaptive large-sized banner
localExtra.put(AdmobATConst.ADAPTIVE_ORIENTATION, AdmobATConst.ORIENTATION_CURRENT);
//localExtra.put(AdmobATConst.ADAPTIVE_ORIENTATION, AdmobATConst.ORIENTATION_PORTRAIT);
//localExtra.put(AdmobATConst.ADAPTIVE_ORIENTATION, AdmobATConst.ORIENTATION_LANDSCAPE);
localExtra.put(AdmobATConst.ADAPTIVE_WIDTH, width);
mBannerView.setLocalExtra(localExtra);
mBannerView.loadAd();
Note: When using Admob's adaptive banner, the height of the banner's parent container cannot be restricted, as shown in the following example:
...
mBannerView.setLayoutParams(new FrameLayout.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
mBannerView.loadAd();
//Call this method before initializing the Taku SDK
TTATInitManager.getInstance().setIsOpenDirectDownload(false)