Help Center/Details/

Self-rendering interstitial

Introduction

Self-rendering interstitial:: Developers can get the material information of the advertisement for splicing

Supported ad sizes:

  • Large picture (Picture with aspect ratio: 1.78)
  • Small image (Picture with aspect ratio: 1.52)
  • Group pictures (three pictures with aspect ratio: 1.52)

Permission

**Self-rendering interstitial ads: ** Reclaimed and no longer available for creation

Self-rendering interstitial request method

Create TTAdNative object

//创建TTAdNative对象,createAdNative(Context context) context需要传入Activity对象
TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(this);

Create ad request type parameter AdSlot

Note:

  1. setImageAcceptedSize is a required field, the desired image size (required)
  2. When setNativeAdType requests native ads, be sure to call this method, request self-rendering interstitial setting parameter to TYPE_INTERACTION_AD
AdSlot adSlot = new AdSlot.Builder()
        .setCodeId(codeId)
        .setSupportDeepLink(true)
        .setImageAcceptedSize(1080, 1920)
        .setNativeAdType(AdSlot.TYPE_INTERACTION_AD)//请求原生广告时候,请务必调用该方法,设置参数为TYPE_INTERACTION_AD
        .build();

Parameter Description

Parameters Description
setCodeId() The code ID created by the platform starts with 9 and 9 digits
setImageAcceptedSize() Expected image size (required) Unit: px
setNativeAdType() Request ad type
setAdCount() The number of requested ads is 1-3

Request ads

The access party can call loadNativeAd(AdSlot adSlot, @NonNull NativeAdListener listener) to load ads asynchronously

//请求广告
mTTAdNative.loadNativeAd(adSlot, new TTAdNative.NativeAdListener() {

	//广告请求失败回调
    @Override
    public void onError(int code, String message) {
       
    }

	//广告请求成功的回调
    @Override
    public void onNativeAdLoad(List<TTNativeAd> ads) {
       
    }
});

NativeAdListener

Callback Description
onError() The error code returned by the ad request failed callback indicates the reason for the ad request failure. For details, please see [link](https://www.pangle.cn/help/doc/5de4cc6d78c8690012a90aa5?from=ad. oceanengine.com&id=5de4cc6d78c8690012a90aa5)
onNativeAdLoad() Callback for successful ad request

Note:
-Before addView, you need to call the removeAllViews method to remove all views on the control
-setNativeAdType(AdSlot.TYPE_INTERACTION_AD) //When requesting native ads, be sure to call this method and set the parameter to TYPE_INTERACTION_AD
-Self-rendering interstitial is to directly create a Dialog, create a layout in the dialog, and add the corresponding advertising elements.

TTFeedAd interface description

Get advertising information through getAdView(), such as title, buttonText, etc., and customize the drawing of the entire advertising area, which can be as close as possible to the style of your own application

public interface TTFeedAd {

    /**
     * 获取穿山甲logo,图片大小:80*80
     *
     * @return bitmap对象
     */
    Bitmap getAdLogo();

    /**
     * 广告标题
     *
     * @return
     */
    String getTitle();

    /**
     * 广告描述
     *
     * @return
     */
    String getDescription();

    /**
     * 广告来源
     *
     * @return
     */
    String getSource();

    /**
     * 广告图标Image
     *
     * @return
     */
    TTImage getIcon();

    /**
     * 广告图片Image list
     *
     * @return
     */
    List<TTImage> getImageList();

    /**
     * 得到Feed广告交互类型
     *
     * @return 2:在浏览器打开网页,3:在app中打开,4:下载应用,5:拨打电话 其它:未知类型
     */
    int getInteractionType();


    /**
     * 得到Feed广告图片模式
     *
     * @return 3 大图 2小图 4 组图 5 视频 其它:未知类型
     */
    int getImageMode();

    /**
     * 获取下载状态控制器
     */
    DownloadStatusController getDownloadStatusController();

    /**
     * 注册可点击的View,click/show会在内部完成
     *
     * @param container 渲染广告最外层的ViewGroup
     * @param clickView 可点击的View
     */
    void registerViewForInteraction(@NonNull ViewGroup container, @NonNull View clickView, AdInteractionListener listener);

    /**
     * 注册可点击的View,click/show会在内部完成
     *
     * @param container     渲染广告最外层的ViewGroup
     * @param clickViews    可点击的View的列表
     * @param creativeViews 用于下载或者拨打电话的View
     */
    void registerViewForInteraction(@NonNull ViewGroup container, @NonNull List<View> clickViews, @Nullable List<View> creativeViews, AdInteractionListener listener);

    /**
     * 注册可点击的View,click/show会在内部完成
     *
     * @param container     渲染广告最外层的ViewGroup
     * @param clickViews    可点击的View的列表
     * @param creativeViews 用于下载或者拨打电话的View
     * @param listener      点击回调
     */
    void registerViewForInteraction(@NonNull ViewGroup container, @NonNull List<View> clickViews, @Nullable List<View> creativeViews, @Nullable View dislikeView, AdInteractionListener listener);

    /**
     * 设置下载监听器
     */
    void setDownloadListener(TTAppDownloadListener downloadListener);

    /**
     * 兼容下载类广告,使用activity申请权限
     */
    void setActivityForDownloadApp(@NonNull Activity activity);
    /**
     * 获取广告的view,如视频广告的view,在广告平台可设置是否自动播放、是否静音等。
     *
     * @return
     */
    View getAdView();

}

Interstitial advertising behavior monitoring

Important!!! AdInteractionListener involves advertising billing, convertView must be called correctly and ViewGroup must be used
**Note: Cannot call ** TTInteractionAd.showInteractionAd in a child thread

/**
  * 注册可点击的View,click/show会在内部完成
  * @param container     渲染广告最外层的ViewGroup
  * @param clickViews    可点击的View的列表
  * @param creativeViews 用于下载或者拨打电话的View
  */
//可以被点击的view, 比如标题、icon等,点击后尝试打开落地页,也可以把nativeView放进来意味整个广告区域可被点击
List<View> clickViewList = new ArrayList<>();
clickViewList.add(mAdImageView);

//触发创意广告的view(点击下载或拨打电话),比如可以设置为一个按钮,按钮上文案根据广告类型设定提示信息
List<View> creativeViewList = new ArrayList<>();
//如果需要点击图文区域也能进行下载或者拨打电话动作,请将图文区域的view传入
//creativeViewList.add(nativeView);
creativeViewList.add(mAdImageView);
List<View> imageViewList = new ArrayList<>();
imageViewList.add(mAdImageView);

//重要! 这个涉及到广告计费,必须正确调用。convertView必须使用ViewGroup。
ad.registerViewForInteraction(mRootView, imageViewList,clickViewList, creativeViewList, mDislikeView, new TTNativeAd.AdInteractionListener() {

	//点击普通区域回调
    @Override
    public void onAdClicked(View view, TTNativeAd ad) {

     }
     
	//点击创意区域回调 
    @Override
    public void onAdCreativeClick(View view, TTNativeAd ad) {
       
    }
    
	//广告展示回调
    @Override
    public void onAdShow(TTNativeAd ad) {

    }
});

AdInteractionListener description

Callback Description
onAdClicked() Click the common area callback
onAdCreativeClick() Click on creative area callback
onAdShow() Advertising display callback

Destroy advertising objects

Destroy the ad view in the onDestroy callback method of Activity

//在Activity的onDestroy方法中清空广告对象
@Override
protected void onDestroy() {
    super.onDestroy();
    if (ad != null) {
        ad = null;
    }
}

Reference Demo

For self-rendering interstitial ads, please refer to the NativeInteractionActivity example in Demo

Self-rendering interstitial notes:

  1. **Cannot call ** TTInteractionAd.showInteractionAd in a child thread
//show弹窗之前一定要加判断
if (Looper.getMainLooper() != Looper.myLooper()) {
       throw new IllegalStateException("不能在子线程调用 TTInteractionAd.showInteractionAd");
  }
  mAdDialog.show();
  1. Self-rendered interstitial ads do not support dislike logic
Did the content solve your problem?
Contact us