Help Center/Details/

Android self-rendering basic module configuration instructions

TTNativeAd object

Effective range:

Scope: Self-rendering information flow, self-rendering Draw, self-rendering interstitial, self-rendering Banner

TTNativeAd interface description

public interface TTNativeAd {

    /**
     * 获取穿山甲穿山甲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();

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


    /**
     * 得到原生广告图片模式
     *
     * @return 3 大图 2小图 4 组图 5 视频 其它:未知类型
     */
    int getImageMode();
    
    /**
     * 获取负反馈选项数据
     *
     * @return
     */
    List<FilterWord> getFilterWords();

    /**
     * 获取“为什么看到此广告”的原因 - //3410版本新增
     */
    PersonalizationPrompt getPersonalizationPrompt();

    /**
     * 得到dislike dialog
     *
     * @param activity 建议传当前activity,否则可能会影响dislike对话框弹出
     * @return
     */
    TTAdDislike getDislikeDialog(Activity activity);

    /**
     * 自定义dislike dialog
     *
     * @param dialog 自定义dialog,需要由外部传入
     * @return
     */
    TTAdDislike getDislikeDialog(TTDislikeDialogAbstract dialog);

    /**
     * 获取下载状态控制器
     */
    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会在内部完成,注册dislike按钮
     *
     * @param container     渲染广告最外层的ViewGroup
     * @param clickViews    可点击的View的列表
     * @param creativeViews 用于下载或者拨打电话的View
     * @param dislikeView   dislike按钮
     * @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 getAdView();

    /**
     * 信息流广告交互回调接口
     */
    interface AdInteractionListener {

        /**
         * 广告点击的回调,点击后的动作由sdk控制
         *
         * @param ad
         */
        void onAdClicked(View view, TTNativeAd ad);

        /**
         * 创意广告点击回调
         *
         * @param view
         * @param ad
         */
        void onAdCreativeClick(View view, TTNativeAd ad);

        /**
         * 广告展示回调
         *
         * @param ad
         */
        void onAdShow(TTNativeAd ad);
    }
}

-The self-rendering banner and the self-rendering interstitial request ads use different types
-setNativeAdType(AdSlot.TYPE_INTERACTION_AD)//When requesting native ads, be sure to call this method, Set the parameter to TYPE_BANNER or TYPE_INTERACTION_AD
-Self-rendering banner is to create a view on the FrameLayout control, add advertising elements to the view, and bind the view to the corresponding control
-Self-rendering interstitial is to directly create a Dialog, create a layout in the dialog, and add the corresponding advertising elements.

Dislike

Effective range:

Dislike logic of self-rendering information flow advertisement and banner advertisement

introduce

The SDK provides the Dislike logic of Information Flow Advertising and Banner Advertising for the access party. When the user chooses to close the advertisement, there will be a prompt asking the user, including "Not interested" and "Have seen" options for the user to choose. This feedback is mainly used for the advertising strategy of Toutiao ads on the client side, to optimize and increase the click-through rate of the ads, to increase the effectiveness of the ads and the revenue of partners.

Ad access Dislike

After obtaining TTFeedAd or TTBannerAd, call TTFeedAd.getDislikeDialog() or TTBannerAd.getDislikeDialog() to obtain the TTAdDislike object. DislikeInteractionCallback selects the result callback interface for the user
The following logic is the logic in the CSJ version 3500 SDK. SDK developers below 3500 version can refer to the corresponding demo for integration

private void bindDislikeAction(View dislike, final TTFeedAd ad, boolean isCustomDislike) {
        if (isCustomDislike) {
            // 使用自定义Dislike,用户选择"为什么看到此广告",开发者需要执行startPersonalizePromptActivity逻辑进行跳转
            final DislikeInfo dislikeInfo = ad.getDislikeInfo();
            if (dislikeInfo == null || dislikeInfo.getFilterWords() == null || dislikeInfo.getFilterWords().isEmpty()) {
                return;
            }
            final DislikeDialog dislikeDialog = new DislikeDialog(this, dislikeInfo);
            dislikeDialog.setOnPersonalizationPromptClick(new DislikeDialog.OnPersonalizationPromptClick() {
                @Override
                public void onClick(PersonalizationPrompt personalizationPrompt) {
                    TToast.show(FeedVideoActivity.this, "点击了为什么看到此广告");
                }
            });
            ad.setDislikeDialog(dislikeDialog);
            dislike.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dislikeDialog.show();
                }
            });
        } else {
            // 使用默认Dislike
            final TTAdDislike ttAdDislike = ad.getDislikeDialog(this);
            dislike.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (ttAdDislike != null)
                        ttAdDislike.showDislikeDialog();
                }
            });
        }


    }
Turn off ad monitoring
DislikeInteractionCallback
Callback Description
onItemClick() Callback when user clicks filterWord in the case of custom style
onClick() User clicked "Why see this ad" in the case of custom styles
onSelected() Default dislike style, click filterWord to call back. Developers can remove ads in this callback
onCancel() The default dislike style, click to cancel the callback
onShow() default dislike style, dislike pop-up window display back
onRefuse() The default dislike style, the user repeatedly clicks the dislike button to call back. Version 3600 is abolished

Download monitor

Effective range

All CSJ advertisement types can monitor the download progress according to this callback

Download callback registration

The SDK provides a download status listener for application download advertisements. The access party can register the listener to monitor changes in the download status. The listener supports callbacks for not downloading, downloading, download pause, download failure, download complete, and installation complete.
Example of use:

//广告对象直接调用setDownloadListener方法
AD.setDownloadListener(new TTAppDownloadListener() {
	//未开始下载
    @Override
    public void onIdle() {

   }
   ...
});

下载监听回调说明

public interface TTAppDownloadListener {

    void onIdle(); // 未开始下载

    /**
     * 下载中回调
     * @param totalBytes 安装包总字节数 -1 :未知
     * @param currBytes 当前已下载的字节数
     * @param fileName 下载文件名称
     * @param appName 当前下载的APP名
     */
    void onDownloadActive(long totalBytes, long currBytes, String fileName, String appName); // 下载中

    /**
     * 下载暂停回调
     * @param totalBytes 安装包总字节数 -1 :未知
     * @param currBytes 当前已下载的字节数
     * @param fileName 下载文件名称
     * @param appName 当前下载的APP名
     */
    void onDownloadPaused(long totalBytes, long currBytes, String fileName, String appName);

    /**
     * 下载失败回调
     * @param totalBytes 安装包总字节数 -1 :未知
     * @param currBytes 当前已下载的字节数
     * @param fileName 下载文件名称
     * @param appName 当前下载的APP名
     */
    void onDownloadFailed(long totalBytes, long currBytes, String fileName, String appName);

    /**
     * 下载完成回调
     * @param totalBytes 安装包总字节数 -1 :未知
     * @param fileName 下载文件名称
     * @param appName 当前下载的APP名
     */
    void onDownloadFinished(long totalBytes, String fileName, String appName);

    /**
     * 安装完成回调
     * @param fileName 下载文件名称
     * @param appName 当前下载的APP名
     */
    void onInstalled(String fileName, String appName);

}
TTAppDownloadListener
Method Description
onIdle() Binding download listener callback
onDownloadActive() Callback in downloading
onDownloadPaused() Download Paused Callback
onDownloadFailed() Download failed callback
onDownloadFinished() Download complete callback
onInstalled() Installation complete callback
Did the content solve your problem?
Contact us